2 Replies Latest reply on Aug 19, 2015 7:57 PM by philmodjunk

    Have onExit script cancel the user entered action?

    LeeMoreau

      Title

      Have onExit script cancel the user entered action?

      Post

      Hi everyone, maybe I'm not doing this the best way but here's my issue.  If a user is on a table and clicks a button to create a related record, my scripts do the relationship and go to the create record page for table B.  Sometimes users click it by mistake and then want to go back, which results in basically an empty record in table B.  So I'm trying to use a dialog box so that if a user leaves the table B layout and has any of 5 fields empty, it pops up asking if they want to cancel and stay on the page, or force save.  I have this working using IsEmpty scripts and the pop up appears as expected.  The problem I have is the default button is cancel, so I've used If Get(LastMessageChoice) = 1, Exit Script.  When the script ends though, it goes on to whatever it was I clicked before.  So if I was on a new record for table B and clicked in the layout dropdown to go to layout G, when I hit cancel on the pop up it just continues on to layout G.  How can I make it so that it cancels out whatever it was the user did or clicked on and stays on this page so they can fix their errors?

       

        • 1. Re: Have onExit script cancel the user entered action?
          LeeMoreau

          Just a quick thing to add as well as I'm seeing it elsewhere.  I have a button on the layout that says Delete Record.  It runs a script that deletes the record then goes to a certain layout.  The problem is it deletes the record as expected, but then when it goes to the next step, it executes the onExit script trigger which pops up the pop up above.  How can I also halt it from running any onExit script?

          • 2. Re: Have onExit script cancel the user entered action?
            philmodjunk

            End your OnObjectExit performed script with: Exit Script [False] and the action that tripped the trigger will be cancelled.

            To keep a script from tripping script triggers, you can use the following method:

            In the script that is tripping script triggers:

            At the beginning of the script:
            Set Variable [$$TriggersOff ; value: True ]

            At the end of the script and at any point where the script can halt or exit:
            Set Variable [$$TriggersOff ; Value: False ]

            In the scripts performed by script triggers:

            If [ Not $$TriggersOff ]
               Put Rest of script here
            End IF