Using scirpt in derived tag

I have created a derived tag with datatype Dataset.
The script marked returns a dataset.

The read expression has no effect the way it is configured right now.

How can i format the read expression so that the return value of the script is used as the tag value?

What kind of parameter does that script expect ?
As it is, you're passing it a string. If it's supposed to be the dataset in the referenced tag, you'll need to use {value} {source} instead of a string.

Another thing to consider: Tags do not depend on a project. So that script needs to be in the gateway scripting project, or it just won't work. Do you have any error in the logs ?

One last thing: I try to avoid scripts in tag evaluation as much as possible. There are countless discussions about this on the forum, but what I (personally) dislike the most about it is how difficult maintenance gets when you have scripts all over the place. I'd probably use a memory tag and a gateway event. Or Phil's integration toolkit to unlock many new expression functions, which might allow you to get rid of the script entirely.
What does your script do exactly ?

Thank you Pascal

The problem was indeed that no Gateway Scripting Project had been defined. I configured the current project as the Gateway Scripting Project and it now works.

Indeed during troubleshooting i reconfigured the script to take the Tag Path and not the {value} as a parameter. I will change this.

And regerding your comment about scripts in tags: i absolutely agree 100%. The cause for doing it this way is legacy compability. The derived tag should bidirectionally convert a rather complex UDT to a Dataset. Its an older PLC that has a rather complex and not very refined handling of production data. I am integrating the PLC with production data from a database (MES functionality).

The plan is to redo the PLC logic at some point in time so that this derivation / scripting is no longer needed. But, temporary solutions sometimes becomes permanent... :slight_smile:

1 Like

I changed the script back to using the {value} instead of the tagpath and it works. Here is an overview of how it works:

1 Like