3 Replies Latest reply on Aug 14, 2012 1:54 PM by RoelfW

    New Record Request in Browse Mode Triggers on Commit Layout Script Trigger

    RoelfW

      Filemaker's documentation states quite clearly that New Record Request in Browse mode create a new blank record.

       

      I have learned that this also means that it triggers the Layout Script trigger On Record Committ

       

      So my nice neat script that checks various things before a record is committed is fired to run on this new blank record

       

      which make no "sense" to a naive user who does not understand or want to understand the underlying Filemaker internal logic.

       

      So I am trying to figure out a simple way to trap this and not run the check script on when new records requests happen in browse mode.

       

      Any ideas on a reliable dependable way to catch this inside a script would be appreciated.

       

      Thanks

       

      Roelf

        • 1. Re: New Record Request in Browse Mode Triggers on Commit Layout Script Trigger
          Mike_Mitchell

          Hello, Roelf.

           

          One way to do this is to embed a check in your trigger script for a given variable and then skip the trigger action if that variable is set. For example, I routinely use "$$noTrigger", and a construct like this:

           

          If [ IsEmpty ( $$noTrigger ) ]

               {do triggered stuff here}

          End If

           

          That way, if you want to bypass the trigger, you simply set your bypass variable to 1 before you do anything that might trigger a script you don't want. In this case, you would trap the New Record command using a custom menu and set the trigger.

           

          There was another method for trapping the trigger. It was more sophisticated, but I can't remember now what it was. Someone smarter than I probably can point you in the right direction.

           

          HTH

           

          Mike

          • 2. Re: New Record Request in Browse Mode Triggers on Commit Layout Script Trigger
            jbante

            FileMakerStandards.org has a page documenting one custom function-based technique for supressing script triggers that basically encapsulates a version of what Mike suggested, but it's designed to handle multiply nested subscripts that may all want to supress triggers for themselves. The FileMaker Weetbicks blog documents another technique using local variables (or none at all!); it's very clever.

             

            One thing about the OnRecordCommit script bears clarifying. When your user creates a new record, your triggered script doesn't run on the new record; it runs on the record the user was already on before the new record is created. When you create a new record, there's an implicit Commit of the current record before that. Your OnRecordCommit trigger runs before that commit (the script can cancel the Commit and the New Record by returning False (0)), then the commit of the current record happens, and then at last the new record is created.

            • 3. Re: New Record Request in Browse Mode Triggers on Commit Layout Script Trigger
              RoelfW

              Thank you both

              Useful, great intro to both sources - more to learn

              always appreciated

               

              Roelf