# Using scirpt in derived tag

**URL:** <https://forum.inductiveautomation.com/t/using-scirpt-in-derived-tag/85553>\
**Category:** Ignition\
**Created:** [February 12, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/using-scirpt-in-derived-tag/85553 "2024-02-12T14:57:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Stave](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@Patrick\_Stave](https://forum.inductiveautomation.com/u/Patrick_Stave)\
**Post date:** [February 12, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/using-scirpt-in-derived-tag/85553/1 "2024-02-12T14:57:48Z")

</div>

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?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/148be9416c2a2725be18fadb25c5bc15dd5fcbd3.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 12, 2024, 3:09pm UTC](https://forum.inductiveautomation.com/t/using-scirpt-in-derived-tag/85553/2 "2024-02-12T15:09:59Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Patrick\_Stave](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@Patrick\_Stave](https://forum.inductiveautomation.com/u/Patrick_Stave)\
**Post date:** [February 12, 2024, 3:29pm UTC](https://forum.inductiveautomation.com/t/using-scirpt-in-derived-tag/85553/3 "2024-02-12T15:29:02Z")

</div>

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... 🙂

---

<div class="post-metadata">

**Author:** ![Patrick\_Stave](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@Patrick\_Stave](https://forum.inductiveautomation.com/u/Patrick_Stave)\
**Post date:** [February 12, 2024, 3:44pm UTC](https://forum.inductiveautomation.com/t/using-scirpt-in-derived-tag/85553/4 "2024-02-12T15:44:51Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/13e00cbb1812b1ab1d0183a6cc73ca5507e48499.png)
