5 Replies Latest reply on Jan 19, 2016 6:41 AM by jonasmn

    Creating portal records?



      Creating portal records?


      I have a set of found records. I'd like to create a record in a related table for each of those found records. I thought I'd be able to use a loop to cycle through each of the found records and create an associated portal record, but I can find no way of creating portal records in a script. I can delete portal records in a script, but near as I can figure, the only way to create records is via the New Record/Request command, which means I must first "go to" that related table, and then do a New Record/Request, which changes the selection of found records. 

      Is there a way to create new records in a related table based on a set of found records in another table? 



        • 1. Re: Creating portal records?

          The only way I know is to CREATE the record in the child-table.  This can be scripted.  There is no create PORTAL ROW as there is a delete.

          • 2. Re: Creating portal records?

            The most commonly used method is to go to a layout based on the portal's table, create the new record set the match field of the new record to the correct value matching to the current parent record previously set to a variable and then return.

            This will not have any affect on your current layout's found set unless your portal is based on a self join and both layouts specify the same table occurrence name in "show records from" in layout setup. in such cases, you can create a new layout based on a different occurrence of the same table to avoid that result.

            It is also possible to create a new record without changing layouts if you set up a special added relationship for that purpose.

            And it's possible to have a script create a new record directly in the portal if "allow creation of records via this relationship" is enabled for the portal's table occurrence in the underlying relationship by having the script go to the last portal row and then setting a field in that portal row to a value--but this last option is not one that I recommend using as it makes your script very vulnerable to breaking should someone edit the layout at some point in the future. 


            • 3. Re: Creating portal records?

              I got it to work by following your suggestion to create the record from the associated table and then return to the parent table and go to the next record. Thanks for that suggestion!

              • 4. Re: Creating portal records?

                It is amazing, back in 1994 I was working in Lotus Approach (database), and there it was a peace of cake to create new records in a portal. But that was more than 20 years ago... We can not expect everything to be better now than before, something has to go backwards too.

                • 5. Re: Creating portal records?

                  For newbies like myself, here is a script solution that gives a neat solution to how to create new records in a portal with child table.


                  1) Create one script "New record" with the steps (sorry for using wrong names, but I have to translate from Swedish):

                  - Move to related post (here you choose the child table and the layout of the child table, this will switch both the table and the layout from the main layout to the layout of the child table. At the same time the correct record is opened, instead of a random one.).

                  - Duplicate post/search post (the current record will be created with all data filled in. Some data like indexes and so on will then be correct, other data will be wrong, but you will fix that with the next two steps).

                  (- Insert todays date (select the Date field in the child table if you have a date field)

                  - Erase (select fields to erase, and repeat this step for as many fields as necessary).

                  2) Place the script button on the main layout where you have your portal.


                  3) Create another script "Back to main layout", with the steps:

                  - Go to layout (select the main table and layout here)

                  4) Place the script button for this second script on the layout of the child table.