You should test for related records first before entering your loop (and subsequently skipping it). Otherwise you may be looping in the wrong context.
And when pasting script text copied from a PDF, please insert the missing returns so that each script step at least starts on a new line.
As i understand it, filemaker does not allow you to create relationships based on calculations.
That's really not the case and I don't see why you need the script or a calculation field.
If you have this relationship:
ParentTable-----<ChildTable (---< means "one to many")
then, if you set a field in ParentTable to "declined". You can easily show all ChildTable records as "declined" without any additional field, relationship or script. If you set up a layout based on ChildTable, you can add the ParentTable::Status field to it and all child records linked to a "declined" parent record will show "declined" in that status field from the ParentTable.
On rare occasions, you may need to add a calculation field for status to the Child table. In such cases, the resulting unstored calculation field will readily show the current status of the related parent record if you give it this calculation:
Which simply copies the value of status from the single related parent record.
I do understand adding a test for related records to this script example. Thank you.
I would like to correct my statement from my first post. FileMaker does not allow you to create relationships based on unstoraged calculations.
I tend to use table relationships that would benefit from unstored calculation results. In the example, ParentTable::Status-----<ChildTable::ParentStatus I would like ChildTable::ParentStatus to equal ParentTable::Status as soon as ParentTable::Status is modified.
So far, mimicking this with scripting has been choice. I need to clean them up and make them more reliable (first checking for related records will go a long way to that end)
are there any other ways to achieve this? maybe un checking the "do not replace existing value" option on a fields auto data enter settings?