# Access UDT parameter in script

**URL:** <https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824>\
**Category:** Ignition\
**Created:** [August 28, 2019, 7:55am UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824 "2019-08-28T07:55:45Z")\
**Posts on this page:** 6\
**Page:** 2

<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:** [September 2, 2019, 6:22pm UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824/21 "2019-09-02T18:22:20Z")

</div>

A job for a derived tag, perhaps, if the member node ID is available? Basically a different write path.

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [December 9, 2020, 6:04am UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824/22 "2020-12-09T06:04:24Z")

</div>

Regarding this,

I have a UDT instance called **T103** (basically I have them from T101 to T120) and under UDT members are as follows:  
_T103_  
_-ID_  
_-Name_  
_-Status_

I tried this approch, reading T103.value in tagPath and later used tagPath=system.util.jsonDecode(str(tagPath)). However when I print this, I get blank dictionary. hence tagPath.keys() doesn’t work either. Am I doing something wrong here?

Also tried eval() instead of jsonDecode its the same {} output. Thanks in advance

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 9, 2020, 12:12pm UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824/23 "2020-12-09T12:12:02Z")

</div>

@Gaurav.Shitole

This thread is specifically about reading structured values over OPC from the built-in Siemens server. I can’t tell from the information you’ve provided if that’s what you’re trying to do or if you should be starting a new topic with more details.

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [December 15, 2020, 5:03pm UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824/24 "2020-12-15T17:03:34Z")

</div>

Hi Kevin,

No I was trying to read a Memory parameter (which will later be converted into OPC) present inside UDT.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [December 20, 2023, 10:56pm UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824/25 "2023-12-20T22:56:46Z")

</div>

> [@nader.chinichian](#):
>
> How can I access UDT parameter in tag change event script?

I came across this thread while considering the same question but on v8.1.35. though I'd add some v8.1 relevant detail.

One oddity I observed is that you can use `{ABC}` style parameter references in a "value changed" script on a member tag in a UDT instance but that appears to resolve the the value of the parameter the last time the UDT instance was restarted, not its current value.

**Update:** Looks like this [documented behavior](https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts#TagEventScripts-UDTParametersinTagEventScripts). Still adding my comment here as a breadcrumb for the next person who forgets the right place in [the documentation](https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts#TagEventScripts-UDTParametersinTagEventScripts) to find this info.  
([Tag Event Scripts - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts#TagEventScripts-UDTParametersinTagEventScripts))

> [@](#):
>
> ### Modern Approach
> 
> Parameters values can be accessed as dictionary values. The benefit of this approach is that value changes to UDT parameters will be reflected in subsequent calls. In most cases, this modern approach is preferable. Thus, if the script needs to access the most recent parameter values on a UDT, and the parameters can change through a means other than editing the UDT (which would restart the tag), then this approach should be used.
> 
> If trying to access the value of a parameter named "myParam" from a Tag Event Script within the UDT, the script would look like:
> 
> `# Reminder: "tag" is a built-in argument on all Tag Event Scripts. Accessing the "parameters" key on the tag argument will`
> 
> `# provide access to all UDT parameters.`
> 
> `paramValue ` `=` `tag[` `'parameters'` `][` `'myParam'` `]`
> 
> ### Legacy Approach
> 
> In Ignition release 7.9 and prior, UDT parameters could be access in Tag Event Scripts with the familiar curly brackets approach. Thus, if trying to access the value of a parameter named "myParam" from a Tag Event Script within the UDT, the script would look like:
> 
> `paramValue ` `=` `{myParam}`
> 
> A large caveat with this approach is that value changes made to the parameter ("myParam", in the example above) would not be reflected in scripts until the UDT was restarted. UDT parameters are pre-compiled, which in this case means value changes are mostly ignored until the UDT is restarted.
> 
> In all cases, the modern approach above is preferred.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [December 20, 2023, 11:42pm UTC](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824/26 "2023-12-20T23:42:33Z")

</div>

I rediscovered this bug/behavior today in v8.1.35. Cross-posting here as it has some relevance. It seems Ignition attempts parameter resolution even on commented lines and will fail silently if there is something in curly brackets that is not a valid parameter.

> [@\[Bug Report\] Curly brackets (braces) on commented line in udt instance script causes script to fail silently](https://forum.inductiveautomation.com/t/bug-report-curly-brackets-braces-on-commented-line-in-udt-instance-script-causes-script-to-fail-silently/79124):
>
> Including open/close curly brackets (braces) with any text in between, on a commented line (e.g. #{z}), in a value changed value event script, on a tag in a udt definition... causes the script to fail silently on UDT instances showing no errors in the script editor and no errors in the logs. Any of these lines causes silent failure of the script with no lines executed. #{L} # here is an innocuous comment that should not affect anything but {does} I tested for the same on atomic tags not in a…

[Previous page](https://forum.inductiveautomation.com/t/access-udt-parameter-in-script/27824.md?page=1)
