When running a scheduled script on FileMaker Server, FileMaker Server will always return a "FileMaker script error" under these circumstances:
1. If your script searches for a found set, and then the script exits after finding 0 records.
2. If your script loops through a found set of records with the "Exit After Last Record" checkbox checked, and then the loop exits after getting beyond the last record.
Even if you've turned "'Set Error Capture" on in your script, FileMaker Server will STILL return an error status message... even if your script ran completely successfully, and even if your script did every single thing that you wanted it to do.
FileMaker Server should only return errors if a real error was actually encountered.
These are the current workarounds for these 2 issues:
1. To workaround the found set issue, you must always keep at least 1 record in your table and then you have to perform a "Show All Records" script step after the "Perform Find" script step. But this is STILL a problematic workaround, because this throws off your expected found set for any script steps that you're about to perform next!
2. To workaround the looping problem, you have to tell the script to exit the loop if Get (RecordNumber) = Get (FoundCount), instead of exiting the loop after the last record.