there is no 'connection' from lineitems to PO at the time when the script runs... Create the foreign record from the parent table (lineitems) via relationship - or start the script in lineitems, store the ID in a $var, go to PO, create a new record and set the foreign key to tha value of the $var
The elegant way is to pass a parameter to the script creating the line item - the primary key.
Once you're in the lineItem creation script, set the field to Get(ScriptParameter) and you're done.
I think the script is for creating a PO from a Line item.
I don't think i want to ask the OP why they want to do such a thing.
As marcus pointed out...
The way the script is written the relationship between line item and Po is not actually established until something causes a commit and nothing in the script causes commit after new PO record is created.
Furthermore the link between PO and Line Items is the LineItemFk in PO so the relationship will not be established until you set and commit the LineItemFk value in the PO table.
In a sense you are telling the set field script to set to a vlaue that depends on itself.
Assuming that the context at start is the Line Item record from which you want to create a new PO.
At a min it should be:
Set Varialble $fk = Lineitemfk
go to Po layout
Set Field PO Line Item Fk = $fk
What a simple fix- thank you! I was clueless regarding the set variable script step. Wish I discovered this forum before knocking my head against the wall numerous times. Thanks for all the quick and helpful responses and Happy New Year to all.
Pick up the FileMaker Training series and work through each exercise. The benefits are huge at the beginning.
will do- and thanks again.