Experiences of a FileMaker Pro Database Developer

Prevent Error 101, Server-Side

When running a script to loop through records and you have the Exit after last checked, you get a 101 error message, record is missing. I “understand” this is supposedly expected behavior, however to me it’s an erroneous error since you have the box checked to exit after last. It’s kind of like “duh, I know the next record is missing, that’s why I’m exiting this loop.”
This is a problem when running the script server-side. The schedule indicates an error and the log viewer shows “FileMaker Script Error.” The script actually performed OK and was successful, but reported the 101 error and shows the error status.
I tried trapping for error 101 and then just exiting the script, but the error was still reported to the FMS log and displayed in the Schedule Window as “FileMaker Script Error.”
The only way around the error is to put a condition to check if you are on the last record, something like:
Exit Loop If [Get ( FoundCount ) = Get ( RecordNumber )]
Put this exit loop condition right before the Go To Next Record script step.

Post to Twitter


  1. Thanks for the tip. The actual calculation is:
    Get ( FoundCount ) = Get ( RecordNumber )

    • Thanks Mark! And your welcome too, I’m glad it helped. That’s what happens when I post late at night. I was “thinking” what the function does and not double checking the actual function. I’ll edit the post to reflect the correct calc.
      Thanks for the feedback and correction,

  2. Thanks for this — I just spent a fruitless hour trying to figure out this very issue. What odd behaviour!

    As a further note, this bug only seems to be an issue if your ‘end loop’ statement is at the very end of the script. I guess the record pointer doesn’t like ending up beyond the end of the found set. I fixed it by adding a ‘Go to record/request/page[first]’ after the ‘end loop’, so that the record pointer ends up, happily pointing to something.

    • Hi Jonathan,
      Thanks for the additional idea and work-around. You will still get the error 101 in your script. This is a standard error with the Go To Record/Request Next when the next record does not exist because you are on the last record. To me this is the problem when you have the “Exit after last” checked. If this is checked, it should just exit without an error because that’s what you want to do.
      Although you will still get Error 101, your script will not end in an error since your last step is now going back to the first record after the end of the loop. So, the script exits on a happy note. If you look at the server log, you will probably still see error 101, but the script will report “OK” when it’s complete since you are now exiting the script when it’s happy instead of exiting on the error.
      All the best,

  3. Gosh, you are right — FM admin console is happy, but my Windows application log notes the 101 script error. However, this is now just an ‘info’ log and not a ‘warning’ log. Phew…

  4. Hi guys, I just ran across this, too. But server isn’t happy with it. I’m running a mac server and it comes up with a script error and won’t repeat the script again. This is very strange. Luckily a lot of the loop functions were just setting boolean fields so I just replaced that chunk with replace field contents. But some of my other scripts actually have to do some functions and run specific data.

    • Hi Ryan,

      So, are you getting stuck with your server-side looping script? When the script wouldn’t repeat and run again, did you look in the Clients section of the Server Admin Console and see if the script was still running from the previous schedule call? I had a lot of trouble with this in the beginning of using server-side scripts and I even tried to use the new abort feature in Server 11 if the script took to long to run. That caused some ugly results and problems with the same script running multiple times. I still think it’s a bug and have reported it.

      The problem was with a locked record which hung the script. It’s very important that you use the Open Record/Request step and then trap for an error. If you get an error, you need to move on to the next record and then make sure that record gets in the queue for the next update the next time the script runs. I even trap for an error on commit record and then do a revert record step if I get an error there, then I skip that record and move on too. You might also want to write to a log file that shows which records were skipped in the process.

      Let me know if this helps,

      • Hi Matt, this article has already helped me nail most of my server side script step alarms, but I have two rather frustrating ones left that Im really struggling to find the answer for, maybe you can help.

        I’m getting error codes 100 (record not found) and 104 file not found. With regard the File not found, it had crossed my mind that as one of the files it refers to in the script is an external file hosted by a separate server, and am wondering if its down to the delay in making the connection to the host that causes possibly even both alarms. We cant use the pause command to give it time to catch up. Also, the error code it reports seems to be generated within a nested part of the script, where the logic is not active. But does the FMPS scan all the script and generate errors even if logical branches aren’t active at run time? This is all very difficult to troubleshoot when working in the dark. Its a shame that FMPS can’t offer a debugger mechanism, as in FMPA. Im using a condition to check if there are related records, if true – go to them, then run through a loop, I already use the exit loop if, as the script uses getnthrecord and variables to traverse through a related record set. I’m pretty sure this isn’t the cause… It all runs fine local but not on the server… do you know any less obvious causes of these alarms, and an alternative to inserting a pause.

        • Hi David. Thanks. Let’s see if I can help with your troubleshooting.

          First, is the error code 100 caused by looking for a record in the external file? Like you said, these errors could be related. However, that is a typical error message if your are going to a related record and there are no related records. You can trap for this error specifically to make the server script happy. The idea is that it’s OK for certain error messages, but then to do something that you know won’t cause an error when you get them; i.e. If $error > 0, then show all records and exit script.

          It’s important that when you are trouble shooting Server-side scripts, as well as writing them, that you click on the “Show Compatibility” drop down and select “Server” when editing the script. This will help to make sure you don’t put a step in your script that Server doesn’t like. As for the External file, I do not think this is supported with FileMaker Server scripts. I need to do a little research here, but the online help specifically says “FileMaker Pro scripts in databases hosted by FileMaker Server.” Make sure to take a look in FileMaker’s built-in help for “Running scripts on FileMaker Server.” I’ll see if I can get confirmation of this, but I’m pretty sure that external table is not accessible.

          Maybe there is another way. What are you trying to do? Set data in your current file or run a script on the related records? Are you looping through those related records from a script on the External file? Let me know and I’ll see if I have any ideas. This might be a job for a robot machine.

  5. Excellent tip. Just came across this issue myself. Actually does make sense that the FMS would report the error as the error also gets reported in the client if debug is on.

  6. Matt, you just saved me a huge headache. Thanks!

  7. Gary Brusanowski says:

    Hey, thanks for this! I was experimenting with Perform Script on Server and ran into this same situation. Of course, the multi-key I was building got obliterated by the error code it sent back instead. Ugh!

  8. I wondered about this and thought, “No, FileMaker could not be this stupid!”. It doesn’t seem to do any harm in my case, but I’ll fix it anyway because I think God is counting all the errors I generate (if so I’m doing a lot of time down under when I first pass).

  9. Thanks Matt for this post.

    I added – Get ( FoundCount ) = Get ( RecordNumber ) right before the Go To Next Record script step – and still getting 101 error – when trying to run the script on server via schedule.
    We are on FM 13.0v9.
    Is this a bug ?

    • Hi Gauree,
      Did you use the “Exit Loop If” script step? Should be in this order:
      Exit Loop If [Get ( RecordNumber ) = Get ( FoundCount )]
      Go to Record/Request/Page [Next; Exit after last]
      Hope this helps,

  10. Thanks for the reply Matt.

    Yes I did use “Exit Loop If” and tested.
    Still got the same error.

    • The way that works best for me is:
      Set Variable [ $n; Value:Get ( FoundCount ) ]
      Set Variable [ $i; Value:1 ]
      Go to Record/Request/Page [ First ]
      //// Do your magic here

      Exit Loop If [ $i = $n ]
      Set Variable [ $i; Value:$i + 1 ]
      Go to Record/Request/Page [ $i ] [ No dialog ]
      End Loop

      In essence, go to the next record by using a calculation…

Leave a Reply to David Crowe Cancel reply