5 Replies Latest reply on Sep 6, 2013 5:02 PM by LaRetta

    OnObjectExit Script Preventing Portal Row Delete

    bradleyboggs

      Hi there,

       

      Thank you in advance for your help! In one of my layouts, I have a portal that has an "OnObjectExit" script trigger that triggers a script designed to validate the data. The only caveat to that is that it prevents the "Delete" button present on each portal row from working (this is just a simple button with the "Delete Portal Row" script step. Button is present on each portal row.

       

      Here's the script that is run OnObjectExit:

       

      If [ not IsEmpty (InvTrans::UnitsIn) ]

      Perform Script [ “Validation_InvTrans_InOut” ] <------------ This script just checks to make sure only one of two fields has a value

      Else If [ not IsEmpty (InvTrans::UnitsOut) ]

      Else

      Show Custom Dialog [ Title: "Correct Transaction Amount"; Message: "ATTENTION - You must include either an IN quantity or an OUT quantity. Please correct."; Default

      Button: “Go Back” , Commit: “No”; Button 2: “Delete Trans” , Commit: “No” ]

      Set Variable [ $m; Value:Get ( LastMessageChoice ) ]

      If [ $m = "1" ]

      Go to Object [ Object Name: "UnitsIn" ]

      Enter Browse Mode

      Halt Script

      Else If [ $m = "2" ]

      Delete Portal Row

      End

       

      The deletion that happens via the dialog works fine - it's just this script trigger/script that is preventing the normal deletion of portal rows.

       

      Any help would be greatly appreciated!

       

      -Bradley

        • 1. Re: OnObjectExit Script Preventing Portal Row Delete
          perren

          Hi Bradley,

           

          The "OnObjectExit" trigger is known as a pre-processing script trigger. The result of the attached script can cancel the triggering event (in this case your delete button).

           

          In the script you outlined you need to use Exit Script with a result of 1 (True) to let the triggering event to continue. As you have it written now your script result is "", which get's evaluated to 0 (False) by the trigger event and cancels any further actions.

           

          Thanks,

           

          --Perren

          • 2. Re: OnObjectExit Script Preventing Portal Row Delete
            bradleyboggs

            You sir, are a godsend! Took me a few minutes of playing around with to find out where to put it so that it would work, but I figured it out.

             

            Put it after the 2nd script step

             

            If [ not IsEmpty (InvTrans::UnitsIn) ]

            Perform Script [ “Validation_InvTrans_InOut” ]

            Exit Script [Result:1]

             

            Thank you again!

             

            -Bradley

            • 3. Re: OnObjectExit Script Preventing Portal Row Delete
              bradleyboggs

              Actually, I was wrong, haha! Putting the Exit Scrip where I did made it so I could delete only certain fields being validated by the scripts...

               

              After much experimentation and trying to grasp what's going on here, below is what finally worked. Basilly like the newb I am, I had too many separate "IF" statements, which is why I could delete some fields After the exit but not the ones before it (in the scripts). So by putting the if statements together (as should have been done in the first place), it worked out:

               

              If [ not IsEmpty (InvTrans::UnitsIn) and not IsEmpty (InvTrans::UnitsOut) ]

              Perform Script [ “Validation_InvTrans_InOut” ]

              Else If [ IsEmpty (InvTrans::UnitsIn) and IsEmpty (InvTrans::UnitsOut) ]

              Show Custom Dialog [ Title: "Correct Transaction Amount"; Message: "ATTENTION - You must include either an IN quantity or an OUT quantity. Please correct."; Default

              Button: “Go Back” , Commit: “No”; Button 2: “Delete Trans” , Commit: “No” ]

              Set Variable [ $m; Value:Get ( LastMessageChoice ) ]

              If [ $m = "1" ]

              Go to Object [ Object Name: "UnitsIn" ]

              Enter Browse Mode

              Halt Script

              Else If [ $m = "2" ]

              Delete Portal Row

              End If

              Else

              Exit Script [ Result: 1 ]

              End If

               

              Thanks again for the help! Headed me in the right direction but still gave me enough trial and error to learn from it. And to learn that it's going to be a long while before I'm actually "Good" at this stuff.

              • 4. Re: OnObjectExit Script Preventing Portal Row Delete
                perren

                Hi Bradley,

                 

                I'm glad you did some experimentation on your own to figure out the finer points of trigger behaviors. I should have pointed you to the resource I referenced up front, but better late than never.

                 

                This PDF is one I keep on hand and reference often when in trigger land: https://fmdev.filemaker.com/docs/DOC-1121

                 

                Happy FileMakering!

                 

                --Perren

                • 5. Re: OnObjectExit Script Preventing Portal Row Delete

                  Here is another terrific resource on script triggers thanks to Wim!

                   

                  http://www.filemakerhacks.com/?p=5333