2 Replies Latest reply on Apr 9, 2010 5:31 AM by LeoB

    Controlling off-record commits. How to disable commits in certain situations?



      Controlling off-record commits. How to disable commits in certain situations?


      Is there a way to keep FM10 from committing when clicking off-record, changing layouts, and so forth? I want to control the committing and only commit on a button-press. The button-press script has a Commit Records/Requests script step.


      I’ve tried to use the Layout Trigger for OnRecordCommit and returning False (which stops the Commit when the user clicks off-record). However, it also triggers when the scripted OnRecordCommit executes. (And in that case I do want it to Commit.)


      Here is the situation in more detail:


      When the layout is opened, a script creates a New Record. One of the fields is automatically filled with today’s date. Another field is required by validation to be non-empty. The layout has two buttons. One says “Save” and the other says “Start over.” The Save button script Commits the record and opens a new one. The “Start over” button reverts and opens a new record. (Both open new records because I don’t want anyone to use this form to browse; the users are just entering info.)


      Also on the layout are a pair of buttons to Show and Hide a log. The log is just another layout opened in another window (showing everything entered so far, as a list). The Show button script creates the window if it does not exist and opens the layout. The Hide button closes the window.


      Here’s the problem: I don’t want to display the FM10 alert dialogs but instead want to control the interaction. If, for example, the user presses Show, FM tries to Commit the record because Show can open a new layout (in another window). I want Show to leave the record open, Show the log, and return to the open record so the user can finish. Another example: the user doesn’t fill out any fields but just clicks off-record. FM tries to Commit the record because it has been made “dirty” by the auto-entered date. In that case, I want FM to just ignore the off-record click.


      Maybe this is way too much information. But I’ve tried various trigger traps and have set flags in global variable and it is getting way too complicated. I’m new to FM (except for using it years ago). I figure you folks must know of a better way to do what I want. Which in summary is: don’t commit unless I tell you to.


      Filemaker Pro 10 on Mac OS X.

        • 1. Re: Controlling off-record commits. How to disable commits in certain situations?

          Hi, you can create 2 scripts. One named "Commit", the other named "CancelCommit". Then apply "Commit" to the button and "CancelCommit" to OnRecordCommit trigger. Here are the steps:


          Set Variable [$$bool; Value:True]

          If [$$bool = True]

          Commit Records/Requests [No dialog]

          End If

          Set Variable [$$bool; Value:False]



          If [$$bool = True]

          Exit Script[Result: True]

          End If

          Exit Script [Result: False]

          • 2. Re: Controlling off-record commits. How to disable commits in certain situations?

            selfcreator (or anybody else that can help):


            I came across this post when trying to figure out a similar script problem;


            I have a layout specifically for creating a new record.  It contains the basic fields that need to be entered and the layout is set to not commit the record automatically.  I have specific buttons to save the record or to delete entries without saving the record.  When the save record button is clicked, a series of checks are done to make sure that required fields are completed and, if so, the record is committed and takes the user to the main record screen that allows related information to be entered via portals.


            I'm not too swift with setting variables, but tried it here instead of a global field because it says that it is faster.


            So, I have a short script OnLayoutLoad that sets a variable $$Commit to False.


            Then, if the user clicks outside of a field I have a script OnRecordCommit:


            If [$$Commit = False]

                Revert Record/Request [No dialog]

                Exit Script

            End If


            I have a Revert Record step in there as I want to take the user right back to the layout/field that they were in.


            The script seems to do it, except that I get the FMP Commit Record dialog box -- which I don't want and don't know how to stop.


            Now, on the Save Record button at the end of the script that checks that all required fields are entered, I have the step:


            Set Variable [$$Commit = True]

            If [$$Commit = True]

               Commit Records/Request [No dialog]

            End If

            Set Variable [$$Commit = False]


            This seems to work.


            Two questions:


            1.  How do I stop that FMP Commit Record dialog box on the first script?


            2.  In your recommended scripts (below) you have Exit Script [Result: True] and the Exit Script [Result: False] after the End If.  I can't figure out what the Result accomplishes.  I tried using them, but still can't get rid of the FMP Commit Record dialog box.