Its a little hard to see your script in the screenshot. Even though the tables are related, in FileMaker context is very important. I would check carefully the context of your script. What layout is the script in when you are trying to perform the step that gives the error? The layout you are in at that point will determine the Table Occurrence for your context. Is that TO related correctly to the table::field in the script step?
Be sure that the base table (TO) of your current layout is the correct TO for the relationship to the portal TO. If you have multiple TOs for a single real table, only the one with the valid relationship is usable as the base TO for the layout if you want the portal to work.
Your correct, i copied this from another table and did not switch those set fields to the new TO.