6 Replies Latest reply on Jun 22, 2017 1:28 PM by siplus

    Resume Script only if N happens

    xxx202xxx

      I have a script where it pauses halfway waiting for data to be entered in 3 fields before resuming with a button click.  My problem is when a user ignores the custom message and clicks the resume but the script resumes.

       

      I would like the following to happen.  If field1 is empty and a Custom Note alerting the user pops up with just a simply 'ok' as an option, I would like for the user to continue to see this pop up until the field is populated.  I would want the same to happen for fields 2 and 3.  Then once all 3 fields are populated then I want the script to continue on its original path

        • 1. Re: Resume Script only if N happens
          mikebeargie

          To achieve this, you need to write your own "error checking" of the user's entry, and force them to correct their mistakes before continuing. You can do this with a loop that is escaped only when the entries are not empty. Like this:

           

          Allow User Abort [ off ]
          Pause Script //IN YOUR SCRIPT

          ( Resume Script //A Button the User Presses to continue )

          Loop

             If [ isempty(field1) or isempty(field2) or isempty(field3) ]

                show custom dialog [ "fields 1,2,3 are required" ]

             End If

              Pause Script //IN YOUR SCRIPT

              ( Resume Script //A Button the User Presses to continue )

              Exit Loop If [ not isempty(field1) and not isempty(field2) and not isempty(field3) ]

          End Loop

          CONTINUE YOUR SCRIPT AS NORMAL

              The above will continue to prompt the user and re-pause the script until they fill in all three fields.

          • 2. Re: Resume Script only if N happens
            philmodjunk

            Have the following code be the first part of the script performed/resumed by clicking your button:

             

            Loop

               Exit Loop If [ ValueCount ( List ( Table::Field1 ;Table::Field2 ; Table::Field3 ) = 3 // all three fields have data ]

               If [ IsEmpty ( Table::Field1 )

                  Show Custom Dialog

               Else IF [ IsEmpty ( Table:::Field2 ) ]

                   Show Custom Dialog

               Else

                    Show Custom Dialog

               End If

               Pause/Resume Script

            End Loop

             

            The if and Exit If expressions can be be made much more sophisticated if necessary to check for more types of user input errors.

            • 3. Re: Resume Script only if N happens
              siplus

              Hide the "Continue" button if ValueCount(List(f1; f2; f3)) ≠ 3, with f1, f2 f3 being your fields.

              • 4. Re: Resume Script only if N happens
                philmodjunk

                That doesn't hide the continue button that automatically appears in the status tool bar, so you'd need to hide the tool bar as well as provide your own "continue" button so that you can hide it.

                 

                And without additional feed back to the user, it could "trap" users in a paused script with no clear direction on what to do in order to get that continue button to appear.

                 

                Not saying that this is a bad idea, just pointing out some additional details that have to be taken into consideration if you choose to go that route.

                • 5. Re: Resume Script only if N happens
                  xxx202xxx

                  Thanks guys I got it to work.

                  • 6. Re: Resume Script only if N happens
                    siplus

                    Which is completely normal.

                     

                    Hiding the status bar is a must.

                     

                    philmodjunk wrote:

                     

                    That doesn't hide the continue button that automatically appears in the status tool bar, so you'd need to hide the tool bar as well as provide your own "continue" button so that you can hide it.