# Creating Dynamic UDT

**URL:** <https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 11, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081 "2024-07-11T14:14:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/1 "2024-07-11T14:14:23Z")

</div>

![UDT Definition Editor (2)](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/4/349361176c9e6713d549ce05239c976e9f5eaaeb.png).  
I have a need to create a tank overview page with over 50 tanks. I was taking the UDT route to minimize the pain of creating repeated tasks.  
As shown in the image, 1, 2, 3 are connections to three different PLCs in the field.  
I was wondering if there is a way to switch the opc path based on the Tank number? or may PLC path dynamic to switch to the right PLC.  
PLC-1 = 33 tanks  
PLC-2 = 23 Tanks  
PLC-3 = about 11 tanks  
I hate to create a separate udt based on PLC. but if that is the only viable route then I will do it. My problem was I could work with only 1 PLC. could not switch based on Tank type

---

<div class="post-metadata">

**Author:** ![Mark\_Minuth](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Mark\_Minuth](https://forum.inductiveautomation.com/u/Mark_Minuth)\
**Post date:** [July 11, 2024, 2:32pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/2 "2024-07-11T14:32:07Z")

</div>

Maybe I'm missing something here, but could you just have custom parameters for both the tank number and the PLC base path? Then dynamically get the OPC path based on both of those.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 2:40pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/3 "2024-07-11T14:40:38Z")

</div>

I have the tank number as input parameter. Based on the Tank number, the PLCprogramName is a memory tag I created under the configuration folder gets the value from a lookup function. I could not pass the tag value to the \_edge\_Plc udt to make the path dynamic.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [July 11, 2024, 3:01pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/4 "2024-07-11T15:01:27Z")

</div>

You're going to need parameters for the PLCs like {DeviceName} that you'll use as part of your OPC path.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 3:03pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/5 "2024-07-11T15:03:36Z")

</div>

@michael.flagler I hope my understanding is correct, I should create 3 parameters PLC1, PLC2 and PLC3 as UDT parameters? Then use if condition to make the selection in the opc path ?

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [July 11, 2024, 3:06pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/6 "2024-07-11T15:06:30Z")

</div>

No, make 1 UDT parameter named "DeviceName" then for each tag specify the device name parameter value as shown under your OPC Devices which could be "PLC1", "PLC2", and "PLC3".  
Your OPC Item Path would be something similar to this depending on your tag structure:

```python
ns=1;s=[{DeviceName}]Tank{TankNum}.Level

```

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 4:31pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/7 "2024-07-11T16:31:27Z")

</div>

![2024-07-11 12_03_20-UDT Definition Editor](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/2/42d646bb6e7d7e86d47df2ff661d5f4625eae7ea.png)  
I hope this image makes it clear to see what I am trying to accomplish.

---

<div class="post-metadata">

**Author:** ![Mark\_Minuth](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Mark\_Minuth](https://forum.inductiveautomation.com/u/Mark_Minuth)\
**Post date:** [July 11, 2024, 4:57pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/8 "2024-07-11T16:57:26Z")

</div>

Not memory tag, but a second custom parameter just like you already have for `edgeTankNo`.  
With Michael's example if you called it `DeviceName` your full OPC Item Path would be:  
`ns=1;s=[{DeviceName}]Tank{edgeTankNo}.Scanner.Out.Level`  
assuming there's nothing else on the end of that OPC path.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 5:13pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/9 "2024-07-11T17:13:32Z")

</div>

@Mark_Minuth - When I create the udt instance, I would have to provide the {DeviceName} text in the parameter. Based on that value it will construct the opc path. Is it correct?  
What I was looking was to get the {DeviceName} from a lookup table and construct the path. I got the lookup working but could not pass the value to {DeviceName}  
Parameter was a static text, that needs to be changed at the instant usage level

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [July 11, 2024, 5:22pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/10 "2024-07-11T17:22:29Z")

</div>

Yes, that is correct, Use the string @Mark_Minuth gave you that is using 2 parameters in the OPC item path. You'll need to specify for each instance the tank number (edgeTankNo) and device name (DeviceName) parameters, but they'll dynamically replace the placeholders and it will work fine.

---

<div class="post-metadata">

**Author:** ![Mark\_Minuth](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Mark\_Minuth](https://forum.inductiveautomation.com/u/Mark_Minuth)\
**Post date:** [July 11, 2024, 5:52pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/11 "2024-07-11T17:52:31Z")

</div>

Grabbing the PLC name from a database or lookup table based on the tank number isn't necessarily a difficult task, but an easy solution for doing that on UDT creation isn't immediately obvious to me.

It sounds like you were binding a tag in the UDT to the plc name based on a lookup from the tank number custom property? I don't think you can use tags in a dynamic path binding, only the properties. You could potentially do it with an initial change script or something on that plc name tag, but really there's only 55 tanks, and you're creating a lot more complication and potential issues than you're solving.

If there were 10000 tanks with 100 different PLCs, I would probably still use two properties, `DeviceName` and `TankNo`, and just write a python script or something to create all the tanks based on that lookup table.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/12 "2024-07-11T18:11:09Z")

</div>

I was taking the lookup route because that way I need to make only one change. Update the dataset and all the paths should update. I am not super comfortable with scripting yet. The last alternative is to manually make 72 connections. which defeats the purpose of having a udt. But I see the stupidity of my approach, passing a tag value to a property is probably not a good idea

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 6:30pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/13 "2024-07-11T18:30:10Z")

</div>

@Mark_Minuth Can you please give some pointers on how to use scripting to create the instances based on the lookup table. Thank you appreciate your help

---

<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:** [July 11, 2024, 6:37pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/14 "2024-07-11T18:37:55Z")

</div>

> [@Anant\_Upadhyayula](#):
>
> I hate to create a separate udt based on PLC. but if that is the only viable route then I will do it.

Consider not including the tanks in the the device's overview UDT. Just use a folder with separate single "core" and multiple "tank" UDT instances.

~~You **cannot** make a UDT with a variable number of members, of any kind.~~

 

Also: You asked a form of this question over here:

> [@Dynamic udt instances](https://forum.inductiveautomation.com/t/dynamic-udt-instances/92767/4):
>
> I meant that you cannot have such a dynamic UDT structure at all. Just use a regular tag folder where you are currently trying to use a UDT.

~~Asking in a new topic won't change that answer.~~

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 11, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/15 "2024-07-11T18:48:32Z")

</div>

I _always_ have the PLC connection name as a parameter to my UDTs, regardless of how many PLCs are in the project.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 7:04pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/16 "2024-07-11T19:04:44Z")

</div>

@pturmel these two are two different applications. They are not same from what I was thinking. The other question was to dynamically populate instances of a sub element of udt based on number of fill heads in the filler. However here I was dynamically trying to change the path of the PLC

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 11, 2024, 7:06pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/17 "2024-07-11T19:06:11Z")

</div>

You can feed parameters down through child UDTs from the parent UDT. This is one reason that I _always_ suffix my UDTs with some sort of identifier that is unique to the UDT.

I'm not quite sure what tags are all within your `_edge_PLC` member, but this should be fairly simple.

If you want the device name for all of the tanks within the PLC to be automatically updated for all tanks at once, create a parent UDT with an instance of the `Tank_udt` for each tank and feed the device name down to the `Tank_udt` instances from the `PLC_Tanks_udt`.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 7:07pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/18 "2024-07-11T19:07:48Z")

</div>

@amarks so if you have 3 tags in a udt that are pulling info from 3 different PLCs. would you create 3 parameters? passing 1 parameter like PLC1 will not be any good for 2 other tags talking to different PLC. Because parameter is a static text for each instance of udt

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 11, 2024, 7:08pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/19 "2024-07-11T19:08:53Z")

</div>

Why do you have tags from different PLCs in the same UDT? That seems a bit odd to me.

---

<div class="post-metadata">

**Author:** ![Anant\_Upadhyayula](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Anant\_Upadhyayula](https://forum.inductiveautomation.com/u/Anant_Upadhyayula)\
**Post date:** [July 11, 2024, 7:11pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081/20 "2024-07-11T19:11:45Z")

</div>

Thats how the site has it, level comes from one PLC. formula is from another PLC and so on.

[Next page](https://forum.inductiveautomation.com/t/creating-dynamic-udt/93081.md?page=2)
