I want a user to be able to do a search in the layout/table “Cages” and then click a button to run a script that will create a new record in a table called “CagesProtocolLineHistory” for each record in the found set.
Below is what I have so far which almost works but on go to original layout line it doesn’t go to the next record, it goes to a record near the end. I.e., it’s skipping some records.

Yes,
Go to Record[ first ]before the loop will ensure that all records are copied. Otherwise, if the script starts at some record other than first, it will skip all records before this.A couple of notes: FileMaker string comparison is case-insensitive by default, so you don’t need to use
Upper()here. Also, in most cases it’s simpler not to copy all data through variables, but pass a single key and copy other data via lookups.