7 Replies Latest reply on Dec 2, 2011 2:43 PM by KatG

    Portal Records

    KatG

      Title

      Portal Records

      Post

      How do I set up a portal to display only the previous record? Is there a way to set the blank entry field to appear at the beginning or top of the portal? Instead of having to scroll through all the records? Any help is greatly appreciated.

       

        • 1. Re: Portal Records
          philmodjunk

          A portal filter might be set up that limits the portal to only the previous record, but I think you might want to try using a button with a script for adding the new portal record instead as you can't change the location of the "add" row in a portal.

          Add a button near your portal that runs this script. (Use your names in place of mine):

          Freeze Window
          Set Variable [$PK ; Value:LayoutTable::PrimaryKey]
          Go to Layout [PortalTable]
          New Record/Request
          Set Field [PortalTable::ForeignKey ; $PK]
          Go To Layout [original layout]

          If you specify a sort order for the portal that sorts on any required field except the ForeignKey field in ascending order, the newly added portal record will appear in the first row of your portal where you can then fill in the other fields.

          • 2. Re: Portal Records
            KatG

             Hi PhilModJunk!

            I was reading through other forum issues and saw your name come up, I had a feeling you would respond to this. I was able to use the portal label as the button and in each table I used a creation date field for sorting and limited the portal rows to 2 with a scroll bar.

            • 3. Re: Portal Records
              KatG

               A tech wrote the script with a few other lines,

              Commit Records/Records [No dialog]

              Go to Object [Object Name: "Layout Portal"]

              Go to Portal Row [Select; First]

              Go to Field [Layout::Field]

              He also disabled the "allow creation of records in this table via this relationship" in the child table.

              I then was able to duplicate the script for other portal fields.

                I am a novice to the Database world, I am just beginning to grasp script writing. I appreciate all the info you have shared in the forum.

              Thank you!

               

              • 4. Re: Portal Records
                philmodjunk

                I don't recommend your tech's approach.

                Interacting directly with the portal like this works, but such a script can fail in the future as it depends on specific layout features in ways that the script I use does not use.

                • 5. Re: Portal Records
                  KatG

                  I am having quite a bit of trouble with script writing. I have the example that the tech wrote (see below) and I have attempted to copy it for use on other buttons... 

                   I understood from the tech that I would need to write a script for each portal field but in the script suggested there is nothing specific regarding each individual field or how to change the prder of the displayed portal records. What am I doing wrong?

                  Set Variable [$TableA ID; Value:TableA::ID_TableA]

                  Go to Layout ["TableB" (TableB)]

                  New Record/Request

                  Set Field[TableB::ID_TableA; $TableA ID]

                  Commit records/Requests [No dialog]

                  Go to Object [Object Name: "TableB Portal"

                  Go to Portal Row [Select; First]

                  Go to Field [TableB::Field]

                  I created a button of the field lable and checked "perform script"

                  This worked when the tech had me uncheck "allow creation of records in this table via this relationship" (but I do not understand why) and there are probably several things I need to check or uncheck.  We added a creationdate timestamp to each table to sort but that created a different record for each field...so I then used only a creation date but I haven't been able to get it to work on other buttons.

                  I want to create to enter the current record into the portal and I want the previous record displayed under it. I do not want to scroll through records in ascending order. I want in descending order but checking this off in the sort options doesn't affect the display.

                  PhilModJunk Are you out there? :)

                  in the script posted by Phil.... Is $PK equal to the primary key or the primary table? I have tried to use your template and I am definitely missing something.  Any help is greatly appreciated. Thanks!

                  • 6. Re: Portal Records
                    philmodjunk

                    You are missing the script step to return you to the original layout:

                    Go To layout [original layout]
                    Go to Object [Object Name: "TableB Portal"
                    Go to Portal Row [Select; First]
                    Go to Field [TableB::Field]

                    Also, Go to Object won't do anything unless you select the portal while in layout mode and give it TableB Portal as the object name in the Name box in the Inspector's position tab. (And apologize to your tech for me for criticizing him. I misunderstood the purpose of this code, (to put the cursor into a field of the new portal record.))

                    the tech had me uncheck "allow creation of records in this table via this relationship"

                    That's because you no longer need that option if you are going to click a button to add this new portal record. The approach you have here avoids having to scroll the portal to get to the bottom "add" row that this option displays in your portal for adding new portal records.

                    We added a creationdate timestamp to each table to sort but that created a different record for each field...so I then used only a creation date but I haven't been able to get it to work on other buttons.

                    That makes no sense here. Adding a cration timestamp should not "create a different record for each field" It should only add one new field to your table that auto enters the current date and time each time a new record is created in the portal's table. This is a good field to specify in your sort order for the portal to sort new records to the top of the portal. You can also define an auto-entered serial number field and specify a sort on it in descending order to get the same "Newest record listed first" order.

                    checking this off in the sort options doesn't affect the display.

                    You can specify the sort order in the relationship details and also in Portal setup. The sort order in portal set up will supercede any sort order you specify in the relationship details.

                    $PK refers to primary key. I didn't know the names of your fields at the time so I used generic terms that you'd update to use the actual field names in your database.

                    PhilModJunk Are you out there?

                    I usually do not access the forum on weekends.Wink

                    • 7. Re: Portal Records
                      KatG

                       Thank you Phil!