I have a session variable bound to an OPC UA variable, and I would like to react to a change of the session variable ShowAcknDialog by opening a dialog. There is no problem when using the XML editor:
No action is performed, even though the variable ShowAcknDialog is definitely changing.
The dialog does open when triggered by other events (for example, a widget click).
What are the differences between XML and JavaScript in how session variable events are evaluated?
In which file should the JavaScript code be placed?
Hi Stephan,
As I wrote, there is no problem with the script when other kinds of events are processed.
And of course, I have a separate file for each piece of content, and all of them are included in the .vis file.
However, the session variable does not belong to any content at the time it changes; only the action leads to the dialog content being loaded. The same behavior is observed in any eventScriptSetId: the session variable change is ignored, even though it clearly changes (as observed on the diagnostic page).
I tried a list binding like yours and it works as expected. When ShowAcknDialogX works, what happens when you use that variable in your list binding? Also check the logger to see if there is any error message. I attached my sample so you can check what might be different.
Hi Stephan,
Thank you for your project.
It seems that the question about where the script should be inserted was the most relevant. It was a bit of a silly mistake on my part, but my intention was to place it in the file related to the dialog that is being opened.
Thank you for your effort.
Best regards
Michal
Hi Stephan,
I have one last question regarding this topic. In XML mode, I have a single EventBinding for a session variable value change that applies to the entire visualization. Regardless of which content is displayed, the dialog is opened.
Is it possible to achieve the same behavior using event scripts? At the moment, it seems that the script must be included in each JavaScript file where the event should occur.
in general the scripts should have the same functionality as event bindings. Its just an extension of what you get in a simplified way with event bindings and actions. I am not sure what you mean with
At the moment, it seems that the script must be included in each JavaScript file where the event should occur.
If the event is a session variable it should be independent from the content that is displayed. Can you explain that in more detail?
If a contentId is present in the script, the script will be content related, which means it is only active, if the content is active, too. If there is no contentId, it is always active, regardless of the active content.
Please notice that “global” scripts cannot reference content related data (e.g. widgets).