To suggest a possible answer, we'd need to see what that sub script: "What if Invoice..." does.
I get that, i was hoping for a oh ya that happens and here is what to do about it.
It collects the data on the current layout, goes to another data base, does a find in that data base and brings back that info along with the original. It then does several calulation script steps ( 30 - 100 depending ) and set 2 fields with the results.
What gets me is if i go to the skipped record, and run the "What if..." script it preforms as expected.From that i "deduced" that it had to be in my loop not the "What if..."
If just started doing it, it has worked in the past. I haven't made changes in the layout...
I'd still like to see that script. My guess here is that something in the other script is changing things in a way that results in the skipped record. Anything that changes the current record or the sort order or omits a record would produce the result that you see.
Either that or the skipped record was open for editing by another user or in a different window on your system and thus an "edit lock" kept the record from being modified. This might be the case if your "set script environment" subscript enables set error capture--a step I don't put in my scripts except in specific cases where I have a script performing a find.
If you have FileMaker Advanced, enable the debugger and step through your script watching your found set, current record, and sort order to see if you can watch the record get skipped.