6 Replies Latest reply on Jul 14, 2015 9:40 AM by philmodjunk

    How to add records to a portal



      How to add records to a portal


      I am trying to make a note sheet with different entries available using a portal.

      I am having trouble being able to add records to the portal from the same layout.  The inventory sample does exactly what I'm trying to do with stock transactions.  Any help is much appreciated


        • 1. Re: How to add records to a portal

          Also I want the records added to be related to the record page it was added on, so that each record in the main layout displays different portal entries relating to that record

          • 2. Re: How to add records to a portal

            Option 1:

            If you enable "allow creation of records via this relationship" in the relationship that links your layout's table occurrence to the portal's, you can add new records to a portal just by typing data into the blank fields of the "add row" that now appears in your portal below the last existing record.

            Option 2:
            Not everyone likes using the Add Row. A button can be clicked that adds a record to the portal. The most commonly used script looks something like this:  (Note that the user will not see the layout changes made by the script.)
            Set Variable [$ID ; value: LayoutTable::PrimaryKey ]
            Go to Layout ["portalTable" (PortalTable) ]
            New Record/Request
            Set Field [PortalTable::ForeignKey ; $ID ]
            Go to layout [original layout]

            Option 3:
            Option 2 can trip a great many script triggers and a portal's "Scroll status", among other things can change due to the layout switches. While lest often done, it's possible to use a secondary "Create" relationship to add the new portal record without actually changing layouts.

            If you have this relationship:

            You add another relationship using a second occurrence of the portal table:
            LayoutTable::TempField = PortalTable|Create::__pkPortalTableID

            "Allow creation...." would be enabled for PortalTable|Create.

            Then this script can be used to create a new portal table record:
            Set Field [LayoutTable::TempField ; "" ]
            Set Field [PortalTable::anyField ; "any value" ]

            • 3. Re: How to add records to a portal

              I understand the relationship part.  Option 1 sounds like enough for me, but I still am confused how to link the portal and the layout table so that it understands that they are related.  I made a field in each called item ID and made the layout one equal to a serial number and the portal field equal to the item ID but that didn't work

              • 4. Re: How to add records to a portal

                Like any other relationship, you set it up in Manage | Database | Relationships. You find the match field in the table occurrence box of one table and drag to connect it to a table occurrence box in another. That produces:

                LayoutTable::IDField = PortalTable::IDField

                You then double click the relationship line to open a dialog where you can select "allow creation..." for the PortalTable (occurrence).

                Note that IDField should be defined to auto-enter an ID each time you create a new record in the LayoutTable. An auto-enter serial number field is still the most often used method for this though it can also be a text field that uses an auto-enter calculation to enter the results of Get ( UUID ).

                • 5. Re: How to add records to a portal

                  Okay awesome.  My only question left is how do I auto enter serial numbers for layout records already created?

                  • 6. Re: How to add records to a portal

                    Show all records on that layout. Put the cursor into the serial number field and use Replace Field Contents from the Records menu. You'll find that there's a serial number option and you can also set it to update your "next serial value" setting at the same time.