12 Replies Latest reply on Dec 5, 2016 5:58 AM by Arie Van Gelderen

    EPDM Dispatch remembers runtime variables?

    Thomas Horst

      I have a dispatch action in EPDM that is set up to fire on a state transition, and fill in the Sales order and line item number of all the parts transitioned, if they aren't already populated.

       

      The first time it runs into one that isn't populated, it will put up two dialog prompting for the numbers. on all subsequent ones, it should just fill in the number it was already given. As it loops through the files, it checks if the variable is blank, and if not, skips over, and also checks if the runtime variables for the line and SO number already exist (if they have, it uses them, if not, it prompts).

       

      I've run into a strange behavior where it seems that after running it the first time, it seems to remember forever what was entered into the runtime variables from previously, and not prompt even when it finds the first blank value on this run. It just fills it with the same thing I input on the first test run without prompting.

       

      Is there a way I can set all runtime variables to NULL each time the script starts? I would have assumed it did this by default for runtime vars. Is this a glitch, or intended behavior?

       

      Thanks,

       

      Thomas

        • Re: EPDM Dispatch remembers runtime variables?
          Iftach Priel

          Thomas,

          Runtime variables stay set just as long as the script runs (hence the name). No need to delete them.

          could the wrong values come from the selected file after all?

            • Re: EPDM Dispatch remembers runtime variables?
              Thomas Horst

              No, I can quite clearly see that the file variables are blank in the data card before the script is run, and the Set variable in the scrip is definitely updating them. on the first time through the loop in the script, it should prompt for the user to input the variables, but after the very first time running the script, it just doesn't. It uses the same value from the very first time I ran it.

            • Re: EPDM Dispatch remembers runtime variables?
              Brian McEwen

              I have not seen this particular thing. But I have a Dispatch script that will prevent a change state if a variable is filled in wrong.  It works fine normally, but if you try to run the change state twice in a row Dispatch fails to stop it the 2nd time, so like you said, it is as if Dispatch did not initialize correctly.

              • Re: EPDM Dispatch remembers runtime variables?
                Thomas Horst

                I created a simplest case test script to confirm the behavior. It consists of one runtime variable, and steps:

                If Var is not blank (already has value), jump to "already has value"

                edit box -> Var

                Label: already has value

                Message box Var

                 

                It behaves exactly the same. The first time you run the script (after it is written, or after restarting), it prompts you for a value and shows it. All times it is run after that, it does not prompt, it just shows the value from the first time. And there doesn't appear to be any functionality in dispatch to write a temporary value into a runtime variable, or clear it. Runtime variables appear to be solely for getting input from edit box or combo box, and they seem to remember that value.

                  • Re: EPDM Dispatch remembers runtime variables?
                    Brian McEwen

                    I assume the runtime variable clears if you exit EPDM?

                     

                    Let me see if I can make sense of your script. I'm just trying to understand it and think if there is another way to structure this, given that bug... 

                    So if the Existing SO does not equal nothing (card variable has a value) the script will skip that file and continue (even if SO Number is nothing).

                     

                    If the SO Number (runtime variable) equals nothing, then the script goes to get two values from the user.

                     

                    Okay, you have the Jump (If-then) on the runtime so that the user does not need to enter it more than once.  

                     

                    ... Have you tried Write Registry Value?  You could put it at the very end. I've never used it, but it might be the thing you need.

                    If you must put in a value you could put in something weird that you also check for with a 3rd Jump.

                  • Re: EPDM Dispatch remembers runtime variables?
                    Iftach Priel

                    Thomas,

                    Any difference in behavior if you run the script on multiple selected files as opposed to single files, one after the other?

                    (just for debugging, when using the menu command "Update SO", and not the transition)

                      • Re: EPDM Dispatch remembers runtime variables?
                        Thomas Horst

                        For the most part, I've been running the test on single files. Maybe it would behave differently for a batch.

                         

                        At first, I had it set up to fire on transition action, but when it wasn't working, I changed it to be a menu command only so I could debug without messing with the workflow. It seems to behave the same in both cases.

                          • Re: EPDM Dispatch remembers runtime variables?
                            Arie Van Gelderen

                            I know it is an old thread but I think I found what is causing the problem. You can't (shouldn't) jump out of the 'for all documents' loop. Check out SPR 695000 "Using a JUMP to step out of Dispatch script 'For all documents' - 'End for all documents' loop causes the script to skip the loop next time it runs"

                              • Re: EPDM Dispatch remembers runtime variables?
                                Thomas Horst

                                I tired editing the script so that all of the jump actions happen inside the loop, and I never jump out of it, but the script still behaves the same. After the first run, it remembers the value input, even on subsequent activations and does not prompt for a new number. Every time I edit the script, it does prompt for a new number. Perhaps it would on a transition too, but based on its behavior on right click menu testing, it remembers the values between executions.

                                 

                                  • Re: EPDM Dispatch remembers runtime variables?
                                    Arie Van Gelderen

                                    I did some testing myself. I added a msg box at the beginning of the script to show the current variable values before the script starts. As you can see in the picture below, dispatch retains the the values of previous executions. So it's clearly a bug.

                                     

                                     

                                    I found another existing SPR in the KB that exactly describes this problem:

                                     

                                    SPR 943795 Dispatch: Runtime variable values are not being cleared after each action resulting in values from previous execution being retained if no selections are made in current acton.