5 Replies Latest reply on Sep 2, 2009 12:11 PM by Orlando

    Custom dialog button behavior

    trialuser1111

      Title

      Custom dialog button behavior

      Post

      I have several scripts within my database that call up a custom dialog with the standard OK and Cancel buttons at the bottom.  However, it seems that no matter which I press, the script continues as though I pressed OK.  How can I assign behaviors to the buttons so that if I press "OK" the script goes in one direction and if I press "Cancel" it goes in another (ideally, stopping the script)?

        • 1. Re: Custom dialog button behavior
          Orlando
            

          Hi trialuser1111,

           

          You need to use the Get ( LastMessageChoice ) Function, and you can use this within an If statement to control the script based on the results.

           

          The result will return a number, 1 - 3, based on the choice. The default is 1 then Button 2 and then button 3.

           

          You script might look like this

           

          Show Custom Dialog [ Message ; Default = "OK" Button 2 = "Cancel" ] 
          If [ Get ( LastMessageChoice ) = 2 ]
          Halt Script
          End If
          Go to Layout [ Ok Layout ]
           

          This script will stop the script running if the user clicks on the Cancel button, otherwise run the rest of the script.

           

          If you use all three buttons you could then use the Else and Else If steps to control different actions after the dialog. 

           

          I hope this helps

          • 2. Re: Custom dialog button behavior
            trialuser1111
               I'm still having a bit of trouble.  When I'm editing the calculation, the note at the bottom of the window says the result must be Boolean (non-zero values are true, zero and empty values are false).  What can I change to allow my If function to accept numeric values?  Also, in your example, the End If script line is indented like the Halt Script line.  When I set mine up, it is not (and apparently cannot be) indented.
            • 3. Re: Custom dialog button behavior
              Orlando
                

              I assume it is the If step you are seeing this message. Input the calculation as below:

               

              Get ( LastMessageChoice ) = 2

               

              This will return a result of 1 if the user clicks the second button, which will give a result of True for this If step and then run the Halt step, Any other button on the dialog will return 0 and will then skip the Halt step. Does this make sense?

               

              The indentation is simply the formatting of the post going wrong and I could not fix it quickly so I gave up, the way you see it in the script editor is correct.

              • 4. Re: Custom dialog button behavior
                trialuser1111
                   That's the way I had it, but since I pasted your version over my own, it seems to be working.  Thank you!
                • 5. Re: Custom dialog button behavior
                  Orlando
                     No worries, glad to help.