5 Replies Latest reply on Oct 8, 2014 7:47 AM by kmtenor

    How to cancel record commit within OnRecordCommit script?

    RedL

      Title

      How to cancel record commit within OnRecordCommit script?

      Post

      I setup a script for OnRecordCommit.  Within the script, I would like to have option(user decide commit or not) to cancel the commit action.  How can I cancel the commit and keep the record same as before it enters to OnRecordCommit?

      I try the other way to have same function.  I have user option UI on each navigator script.  It works for the above requirement.  But, how do I know the record and portal records are changed? I would like to show the commit or cancel UI only when record and/or portal records are changed.

        • 1. Re: How to cancel record commit within OnRecordCommit script?
          Abhaya

          Hello Redl,

           According to your problem...........

          Just write a script  ....

          show custom dialog box: Are u want to save/commit

          if yes then  commit record/request

          else

          revert record /request

          This must be attached by script trigger (on record commit)

          You must check the box: save record changes automatically from layout setup.

          This'll perform after u entered values  in the field then click on outside the field

           If u want  to  perform this after the  value entered in the last field on the layout then

          create a button(Say save) which  attached by trigger (on record exit) by a script only  commit record/request.

          I hope this'll bring ur Ans

          • 2. Re: How to cancel record commit within OnRecordCommit script?
            philmodjunk

            A script triggered by OnRecordCommit executes before the record is actually committed. Thus, all you need to do is exit the script without actually committing the record:

            Exit Script [False]

            will do that.

            All "before event" triggers can be canceled in this fashion

            If you look up "Setting up script triggers" in FileMaker help, you'll find a table  listing all triggers and which are "before" triggers.

            • 3. Re: How to cancel record commit within OnRecordCommit script?
              RedL

              Thank you for your clear info.  I follow your suggestion.  It works on the Commit.  But not Revert.  Here is my result.

              1. I have two bottoms which execute Commit and Revert script directly.
              2. I trig scripts by OnRecordCommit and OnRecordRevert.
              3. Both SKU_FormCommit and SKU_FormRevert script is exact same - ask to save/revert or not.  And my result is below.
              For the Commit:
              Record data was "111".   I changed it to "222".  When I click "Save" bottom, the record data on the screen is still "222". System jumps into my commit script and asks save or not.  The script "Exit Script [result:False]" and Exit Script [result:True]" work exact what I want.
              For the Revert:
              Record data was "111".   I changed it to "222".  When I click "Revert" bottom, the record data on the screen  changes to "111" right away before system jumps into my revert script and asks revert or not.  The script "Exit Script [result:True]" reverts the data to "111".  And "Exit Script [result:False]" keeps the data on the screen as "111".
              My question:  Should the screen be "222" when I click "revert" and when I "Exit Script [result:False]"?

              • 4. Re: How to cancel record commit within OnRecordCommit script?
                philmodjunk

                With

                Exit Script [False]

                there is no need to revert the record as it is never committed.

                • 5. Re: How to cancel record commit within OnRecordCommit script?
                  kmtenor

                  I ran across this post while attempting to use the onRecordCommit technique in Filemaker 13 to prevent records from being changed after a supervisor has closed the record to changes.  Despite the insistence of this post and the Filemaker documentation, I could not make the record not commit with a simple "Exit Script [Result: False]" step following the test.  I had to put in the "Revert Record/Request" step instead in order to get out of the record.  Without the "Revert Record" step, the layout remains locked on the record and the user continually gets the warning message from my onRecordCommit script that they are not allowed to change the record.

                  Am I overlooking something?  The results are still as expected - the record is not allowed to be changed.  But what I had to do to make that happen doesn't match with any information I can find in documentation or online.

                  Thanks.

                  -Kevin