1 Reply Latest reply on Apr 7, 2014 6:52 AM by philmodjunk

    Opening Multiple New Records in a Portal?

    BrianPearson

      Title

      Opening Multiple New Records in a Portal?

      Post

            I have a database that hold repair records for products returned by the customers.  Each record has a unique FR number which is also the record "key".  I want to raise multiple new records (approx. 10) when a batch of items are being returned by a particulate customer. I want to raise a return authorisation number, a bit like an invoice number, that will be given the list of new FR numbers.  The list of new FR numbers would then be used to raise new records.  It seems like an editable portal could be used but I can't figure out how to make the portal raise the multiple new records. Any hints or help would be greatly appreciated.   

        • 1. Re: Opening Multiple New Records in a Portal?
          philmodjunk

               You'd use a script for this.

               The details will vary depending on how you specify the precise number of records to create. The following example assumes that gNewRecs, a global number field has had a number entered into it just before the following script is performed. It also assumes the following table occurrence names and relationships:

               LayoutTable::FR = PortalTable::FR

               Use your actual table and field names in place of mine. A field with global storage specified can be defined in any table in your file and this script will still work so it does not have to be defined in a table named "globals".

               Freeze Window
               Set Variable [$FR ; Value LayoutTable::FR ]
               Go to Layout ["PortalTable" (PortalTable) ]
               Loop
                   Set Variable [$K ; value: $K + 1 ]
                   Exit Loop If [ $K > Globals::gNewRecs ]
                   New Record/Request
                   Set Field [ PortalTable::FR ; $FR ]
               End Loop
               Go to Layout [original layout]

               But keep in mind that you don't have to use a script to create new records in a portal. If you enable "allow creation of records via this relationship" for PortalTable in the above relationship, you can simply start entering data in the portal and FileMaker will create a new record in the portal table and automatically copy over the FR value to link it to the current record shown on your layout. So you can create portal records very easily on an "as needed" basis without using any script.