2 Replies Latest reply on Feb 10, 2017 7:47 AM by philmodjunk

    script trigger infinite loop

    tracievans@mobileda.org

      We have had an issue where there is no consistency in how a report number is being entered within Filemaker.

      It is a text field because the report number starts with abbreviations to inform the user of which county the report came from and then the rest of the report number finishes up with the year, month, and individual report number.

      Some people are adding dashes, some are adding a a 2 in front of 17 (to represent 2017) and my boss wants me to make it where there are no dashes and no 2 so that everyone knows how to properly search for a report number. Right now it's a guess of whether there are dashes or a 2 in front or not.

      For example: M-217-02-1234 should be M17021234

      So I have created an onObjectExit script trigger that will remove the dashes and the 2 right after the M.

      However, that has me stuck in an infinite loop because every time it tries to exit the field (commit record), it starts the script all over again.

      I have tried several different script trigger options but the same thing happens.

      Can someone please tell me how to get out of this loop within the script!!!

      I need this completed ASAP.

       

      I have tried exit script, commit records, and install ontimerscript just restarts the script every time the time runs out.

      I am using a MAC with Filemaker 15 pro advanced and sierra OS, server is filemaker server 15.

        • 1. Re: script trigger infinite loop
          philmodjunk

          Sounds like you are using script steps that require that the cursor be in the field, steps that start with "insert" come to mind and these are usually not the ones to use for this. Set Field does not require that the cursor be in the field being modified so that may be a better option.

           

          In general, you can keep a script from performing scripts by tripping script triggers if you do this:

           

          In scripts performed by script triggers, make these the first executable lines of your script:

          If [ $$TriggersOff ]

             Exit Script

          End IF

           

          In scripts where you need to disable those scripts add in this code:

           

          Set Variable [ $$TriggersOff ; Value: True ]

          put code that trips triggers here

           

          And at any point where a script will halt or exit, this step must be executed first:

           

          Set Variable [ $$TriggersOff ; Value: "" ]

           

          This method works even for scripts that trip their own trigger.

           

          But you might want to post your script and you might want to consider using an auto-enter calculation instead of a script to get a correct format.

           

          And I recommend that you not use this field as  Primary Key to link records in relationships.

          • 2. Re: script trigger infinite loop
            tracievans@mobileda.org

            Thank you! That worked!!!!