You can "loop create". Take the primary key of the parent record in Table 1 and set it to a variable. Set the # of people to another variable. Then go to a layout with the Table2 records with the rest of the script something like:
Set Variable ( $count ; 1 )
create one new related record for each person needed
Set field ( Table2::foreignkey ; $varPrimaryKeyPassed // this "sets" the new record to be related )
Set Variable ( $count ; $count + 1 // increment )
Exit Loop if ( $count > $numPeople )
"blank row at the bottom" is normal when you've enabled the "create" option in the relationship used to make the portal possible. Remove that option to remove that blank row. You can still add related records through one of two options:
1) Use a script like this: (assumes the following relationship:)
LayoutTableOcc::PrimaryKey = PortalTableOcc::ForeignKey
Set Variable [$Qty ; value: LayoutTableOcc::#OfPeople ]
Set Variable [$ID ; Value: LayoutTableOcc::PrimaryKey ]
Go to Layout [ "PortalTableOcc" (PortalTableOcc) ]
Set Variable ]$K ; value: $K + 1 ]
Exit Loop If [ $K > $Qty ]
Set Field [PortalTableOcc::ForeignKey ; $ID ]
Go to Layout [Original Layout ]
2) Look up the "MagicKey" method. This requires a second relationship to a second occurrence of PortalTableOcc with Create enabled, but allows you to create any number of related records without changing layouts.
When I try to do option 1 my script won't let me fill in "Set Field" the way either you or beverly have shown. I can get
Set Field [PortalTableOcc::ForeignKey]
but do not see how I input
Set Field [PortalTableOcc::ForeignKey; $ID]
in there. If I try to type it it won't recognize the line of script, if I allow it to auto complete the line there is nowhere to enter the variable. Should I be using the calculated result instead of specifying target field?
There are two parameters for set field. Target Field and calculated result. Select "target field" to specify the field for the parameter to the left of ; . Select "Calculated result" to enter the expression to the right of ; . Do not enter the semi-colon.