Few days ago, we had a post that talked about a very similar behavior : It was with the OnObjectModify trigger where the poster wanted to pass in parameter the value after modification. But the script parameter passed the state of the field before the action, which was very handy, in order to get the original value, but not what the poster expected.
I realize that doesn't help you, but i think that it is the expected behavior to all "post" triggers :
- Parameters Evaluation
- Event processing
- Scrip execution
One idea from the poster, that can apply here, was to pass a text formula and then Evaluate it on the target script.
Good suggestion. In most circumstances the functions can be called within the script but when we are dealing with well-established script libraries we don't want to modify them. We simply want to pass them the parameters that they need.
OnPanelSwitch is a "pre" trigger - in other words - the script is run before the panel switch occurs.
I see this as a bug because I think the actions occur in this sequence:
- Interaction with the Tab Panel raises "OnPanelSwitch" signal
- Script Triggers are tested and we find a trigger for OnPanelSwitch
- Calculation stored in Script Parameter Calc Box is evaluated
- Script is triggered and passed the result of the calc in the script parameter box
I don't know the exact sequence of events three and four but they certainly occur after OnPanelSwitch. At that point I expect the system knows the TriggerTargetPanel, so it seems strange that the values aren't accessible to the script parameter.
What is really weird is that TriggerCurrentPanel returns zero in that circumstance too. How is it that the current panel information is unavailable?
Your sequence sounds absolutely true and i obviously took a bad example, focusing on "post" trigger and passing parameters to it, accordingly to antoher recent post.
But in your case, your are using a calc fonction that is only valid when the triggered script is executed (or just triggered that is the question, isn't it?) ... The rest of the time it returns 0. To me, the help is clear about the behavior and i always understood it as it is :
"Returns an index value, starting from 1, when running a script triggered by the OnPanelSwitch
I also tested Get(TriggerModifierKeys) and it behave the same. It evaluates only after the script starts.
I am sorry that doesn't help you and i encourage you to post a Feature Request here. If this one is changed, i cannot imagine a case where an existing code would be broken, so, to me, it would be a fair suggestion. .
thanks for posting that excerpt, especially with the highlighting. So, with my lawyer glasses on, I can see that we can only expect these functions to return sensible values from within a script. But why have they limited the scope of the function to be within a script when there are opportunities for calculations to occur in so many other places?
Once you understand the context rules for parameters, you can use many different functions inside a script parameter function with no issue, but not a function set up to determine a value as a result of tripping the trigger that performs the script.
Thank you for your post.
The information from "Fred" is correct (Thank you!). In essence, the script parameter is evaluated before the modification and before the script is triggered. The example with OnObjectModify can be found at:
Since this issue has not been previously reported for Get (TriggerCurrentPanel) and Get (TriggerTargetPanel) functions, I have sent this thread to Development and Testing for review. When I receive verification, I will let you know.
Development has confirmed that these two functions return the index value only when called from a script activated by the OnPanelSwitch. Otherwise, 0 (zero) is returned. The script is triggered before the switching occurs so it passes the value 0 to the script before the script is executed.
The Help for FileMaker Pro 15 has been updated to reflect this result.
Help -> Reference -> Script triggers reference -> OnPanelSwitch
Under the Notes section, the second bullet point reads:
"Because this trigger is activated before the panel switch event is processed, the value of the script parameter that OnPanelSwitch passes to your script is determined before the panel is switched. Therefore, if you use the script parameter to pass the returned value of Get(TriggerCurrentPanel) or Get(TriggerTargetPanel) into your script, the value will be zero. To get useful returned values, use these functions only within the script activated by OnPanelSwtich, not in the script parameter."
Had the same issue. This can be solved by using an intermediary one-line script that only performs the original destination script with the script parameters you originally used directly on the tab panel, which will then be evaluated as they are done in the intermediary script.