Let's build a ForEach Loop

Discussion created by on Apr 20, 2017
Latest reply on Apr 22, 2017 by

I need to update data in one table from updated data in another table.


I have a master list of manuals with revisions. I also have a list of instruction forms which require a list of manuals. These forms and manuals are unique based on the item being worked on. So the same instruction list will be the same for each of the same item. But not all items are the same and the different ones will have a different set of manuals.


When the manual revision changes I need to reflect this on the instruction form when the new form is printed.


So, what I've done is to create the master table of manuals with revision (versions), date of revision and a concatenated field of Manual/Revision. When the revision of the manual changes I want to create a script which will then change all instances of the same manual/revision (concatenation of Manual and Revision) based on the new data. The changes will take place in the Manuals instruction form table.


Yes, two tables have the same data. Yuck..... but this is necessary because I must be able to refer to the past instruction form's manuals when it is from a later date and it must show the version of the manual used at that time. The changes must be reflected on any 'jobs' after the manual has changed.


OK now to what I've done... I have successfully been able to change the data in the Manuals on forms table through a find and replace contents script step.


What I want to do is avoid writing the same script steps 35 - 50 times one for each different manual for each different form.


I thought it might be possible to create a 'list of fields' which could be in a container of sorts. Then using a Loop, loop through each of the 'contained' fields to perform the necessary script steps. In C# it is simple to perform a ForEach to iterate through the contents of a container.


I can't find the equivalent 'tool' in Filemaker Pro 15.  I either have to execute the same script for each of the fields in the table that need to be changed or I come up with a way to loop through all the fields in the table and perform the same script for each field.


Any thoughts?