I'm trying to populate a table using a binding and a script transform.
The script is performing a "tagBrowse" in a folder and parsing all required data:
Everything is working as expected but I'm not able to use the message handler to refresh the binding and let the script run again to browse the tags again.
This is the "Script Configuration":
And this is how I'm temporary trying to trigger the message handler using a button:
I'm probably missing something
Any help will be appreciated.
Thanks in advance
Refresh doesn't really do anything to a tag binding. They always auto-refresh with new data. Refresh will only re-run a transform on a binding if the binding itself gets a new value.
Consider moving that script transform to a project library function and calling it separately where needed. Perhaps as a
runScript() binding instead of a tag binding.
Thanks for your help, it is clear now the reason why the table was not updating.
Regarding the script unfortunately due to some restriction in our environment I can't run script in the project library, so I need to find a different way to achieve it
That sounds more than a bit strange. Not being able to leverage project script functions to reduce code duplication would be an extraordinarily bad policy. You should get that restriction lifted.
Thought that I should also mention running a browse operation like this directly in a script transform is potentially crushing your performance, depending on how many tags are within
'[default]Trucks', not to mention you're doing tag operations on paths that are potentially not actually tags.
Also, you loop through these results and then run two read operations each time through the loop. At a minimum that should look like:
tagRead, PLC = system.tag.readBlocking([strTagPath + '/expression/ActiveAlarms',strTagPath + '/Parameters.PLC'])
However, I would strongly consider building a list of all tag paths and then reading them all at once.