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.
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.
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!
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.
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.