4 Replies Latest reply on Aug 31, 2016 9:12 AM by flybynight

    Install OnTimer Script and optional script parameter bug

    alex117

      Product and version (FileMaker Pro Advanced 15.0.1.119)

      OS and version (OS X, El Capitan, 10.11.6)

      Hardware (MacBook Pro)

       

      Description

      The Install OnTimer Script step seems to have a bug involving the “optional script parameter” option available in it. When you specify the “Get ( ScriptParameter )” function as the value for the optional script parameter, the actual value of the script parameter does not pass over into the subscript specified within the Install OnTimer Script step.

       

      For example, let’s say you have a simple text expression of "Hello World" defined as the script parameter for a particular script trigger. You then have a timer script with Install OnTimer Script step to run a particular subscript. You want to pass that original "Hello World" script parameter previously mentioned to the subscript. This is normally done by (1) specifying the “Get ( ScriptParameter )” function as the value for the optional script parameter of the Install OnTimer Script step and then (2) using "Get ( ScriptParameter )" again within the subscript to get the original "Hello World" value. In this scenario, the value does not pass on for some reason.

       

      *The interesting thing is that the Perform Script step also has an “optional script parameter” option and it allows the use of the “Get ( ScriptParameter )” function as the value for that, and in that instance, the value of the script parameter is actually correctly passed on to the subscript selected.

       

      I’m not sure if this is by design, but I cannot find any documentation. It seems more like a bug since the "optional script parameter" option should behave more like the one available in the Perform Script step, but it doesn’t.

       

      How to replicate

      Please see the attached file.

       

      Workaround (if any)

      The only way to get the original "Hello World" script parameter over to the subscript of the timer script is to first define a global variable equal to "Get ( ScriptParameter )" and then use that newly created variable as the actual value for the optional script parameter for the main timer script, instead of just using "Get ( ScriptParameter )". This means an extra step, since you don't have to do this in the same option found within the Perform Script step, but it works.

       

      I hope FileMaker will look into this and make the behavior of the optional script parameter more consistent and compatible with the "Get ( ScriptParameter )" function since it already works well within the Perform Script step and avoids the extra variable step.

        • 1. Re: Install OnTimer Script and optional script parameter bug
          TSGal

          alex117:

           

          Thank you for your post.

           

          This is by design and is consistent with all other script triggers.  When you install an OnTimer script, FileMaker saves the calculation expression and is evaluated when the OnTimer script is actually triggered, which could be hours later.  At that time, there will not be a value for Get (ScriptParameter) because FileMaker never fires OnTimer during execution of another script.  If you want to save a value for later, then, as you discovered, use a global variable.  This calculation evaluation at time of trigger is the same as all other script triggers.

           

          TSGal

          FileMaker, Inc.

          • 2. Re: Install OnTimer Script and optional script parameter bug
            alex117

            Oh I see, thank you for your answer.

             

            So essentially the subscript acts as a separate stand-alone script. I noticed that you cannot pass local $variables to it through the optional script parameter either, so it behaves a lot like a separate script where you would have to share those values with it by using global $$variables.

             

            That's interesting. It would be a little helpful if FileMaker added an update to the help documentation for the Install OnTimer Script step to make a note that the "Get ( Script Parameter )" function when used as the optional script parameter behaves differently here by design. It seems others have had this question too from similar posts I've encountered. I was a little confused since the script step interface for Perform Script is strikingly similar, but there you can successfully pass local $variables and also use "Get ( ScriptParameter )" in the optional script parameter to share the data with the subscript. Thanks again!

            • 3. Re: Install OnTimer Script and optional script parameter bug
              TSGal

              alex117:

               

              I have sent your comments to the manager of Product Documentation.

               

              TSGal

              FileMaker, Inc.

              • 4. Re: Install OnTimer Script and optional script parameter bug
                flybynight

                I find this very interesting… and just happen to experience a similar thing trying to pass $vars in the optional parameter for "Install OnTimer Script"

                You say that it is consistent with all Script Triggers… but you call it more like a similar way that you call another subscript. And in that case, it could be seen that "Perform Script" and "Install OnTimer Script" behave in an inconsistent manner. For example:

                If I use the "Perform Script" step, I can put a $var in as the parameter, and it is evaluated in the parent script, so it can pass the value of that $var to the subscript.

                But if I do the same thing with "Install OnTimer Script" you are saying that it does not evaluate the script parameter in the parent script, but rather in the sub (OnTimer) script… at which point the $var will have no value.

                The "Install OnTimer Script" optional parameter is the only place that I can think of that does not evaluate a $var in a calculation, but rather passes it as literal text.

                 

                It seems to me that would not be the desired behavior most of the time. It would be nice if you could pass parameters to an OnTimer without having to resort to $$vars. But at the very least, alex1117 is correct that this should be called out in the documentation.

                 

                Thanks!

                -Shawn