Your script loses the focus on the portal row when it changes layouts. Thus references to the portal table refer to the first record by default.
Your script also leaves disconnected records in the portal table instead of deleting them.
Thanks, removing the change in layout has fixed it, however, if I want to incorporate marking an artwork as available (in it's status field) how do I do this when removing from the portal at the same time?
Option 1: Set up and use a relationship to an occurrence of that table which allows you to modify the value of this field without changing layouts. If I read you relationships correctly, you can set a field in "Artwork for consignments" to do that.
Option 2: Set a variable to the artwork ID. After deleting the portal record, switch to a layout for that table, use the value in the variable to perform a find for the record, update it and then return to your original layout.
Thanks! on a more obvious level, I have a portal here to artwork so I can just add the status field to that portal so the user can see for themselves what it is and change it accordingly.. Maybe thats what you meant!?
What did you mean earlier by "Your script also leaves disconnected records in the portal table instead of deleting them. "?
It's not what I meant, a field does not have to be visible on the layout in order for it to be modified by a set field script step. But you do need a way to correctly reference the correct record of your table and if you have a relationship in place that does that, your set field step can simply refer to the name of the appropriate table occurrence.
What did you mean earlier by "Your script
You have been clearing the match field of your portal record. This makes it disappear from your portal as it is no longer linked to the current consignment form record, but it's still there in the portal's table. This can create possible problems for you for a number of different database tasks so I would not do it that way. I'd delete the record.
thanks, could you explain how option 1 works in a bit more depth?
I need a field in artwork for consignments that links to the table (and portal) - consignment line items - and allows editing of status? How does that work? thanks!
Not sure what more to say about option 1. I've recommended using:
Set Field [ Artwork_for_Consignments::Status ; "Available" ]
while the focus is still in your portal row (which is based on Consignment Line Items).
The text in blue is the name of a table occurrence in your system. When a script step or calculation refers to a table occurrence, it tells FileMaker both what table to access, but also what relationship to use in order to determine what record in that table to access.