# I need help in writing a script to dynamically update expression in a tag

**URL:** <https://forum.inductiveautomation.com/t/i-need-help-in-writing-a-script-to-dynamically-update-expression-in-a-tag/100362>\
**Category:** Ignition\
**Created:** [January 1, 2025, 10:32pm UTC](https://forum.inductiveautomation.com/t/i-need-help-in-writing-a-script-to-dynamically-update-expression-in-a-tag/100362 "2025-01-01T22:32:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tex\_Hen](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@Tex\_Hen](https://forum.inductiveautomation.com/u/Tex_Hen)\
**Post date:** [January 1, 2025, 10:32pm UTC](https://forum.inductiveautomation.com/t/i-need-help-in-writing-a-script-to-dynamically-update-expression-in-a-tag/100362/1 "2025-01-01T22:32:36Z")

</div>

Hello Everyone,

I need a script that will dynamically change the values of the expression tag using the dataset in a memory tag.  
In this example, for PCS 23 CB10 DC current tag, I need the module # and the CT # to be updated from the dataset in the memory tag.

From the data set, "InverterNumber" is my PCS #(which is 23 in this example), "CBNumber" is my CB #, "ModuleNumer" should update the Module # in the expression and "DCInput" should update the CT # in the expression.

So for this PCS, the expression in the **DC Current** tag should update to **Module 2** and **CT 4**.  
I have 32 PCS the script should loop through. Thanks

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 1, 2025, 10:44pm UTC](https://forum.inductiveautomation.com/t/i-need-help-in-writing-a-script-to-dynamically-update-expression-in-a-tag/100362/2 "2025-01-01T22:44:27Z")

</div>

Seems to me you should be using reference tags, and simply write to the `source` configuration property according to your dataset.

(Please edit your title to actually reflect your question.)

---

<div class="post-metadata">

**Author:** ![msteele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/msteele/32/77889_2.png) [@msteele](https://forum.inductiveautomation.com/u/msteele)\
**Post date:** [January 2, 2025, 6:47pm UTC](https://forum.inductiveautomation.com/t/i-need-help-in-writing-a-script-to-dynamically-update-expression-in-a-tag/100362/3 "2025-01-02T18:47:04Z")

</div>

Looks quite clear that you're managing inverters at a utility-scale PV or BESS plant. Have you considered nesting UDTs to create these structures? It makes things much easier.

Our UDTs for a few inverter vendors use parent/child inheritance _and_ nesting. We have namespace UDTs that are vendor-agnostic, then we have vendor-specific UDTs for PCS, Module/Inverter, and DC input (CB in your model). Then, for particular models, we have child UDTs for module (which includes `n` nested DC inputs of the model-specific child) and PCS (which includes `x` nested modules of the model-specific child). This has proven highly flexible as we integrate new models and variants from existing inverter vendors in our library.
