Can I Dynamically Input Data Into a UDT Parameter Based on a Query Tag?

Hi everyone,

I'm working on a project where I use UDT instances to represent machines (e.g., Machine-1001, Machine-1002, etc.).
Each UDT has a parameter like machine_no that I use to drive indirect tag paths or bindings inside the UDT.

I also have a Query Tag (executing every second) that returns a dataset from a SQL database — this includes the machine number and some runtime values.

What I want to do is:

  • Match each row’s machine_no to an existing UDT tag name (e.g., match 1001 to Machine-1001)
  • Then update the machine_no UDT parameter of the matched instance from the query result

Example:

  • Dataset returns: machine_no = 1001
  • Match to tag: [default]Factory/Machine-1001
  • Goal: Set [default]Factory/Machine-1001’s parameter machine_no = 1001

My questions:

  • Is it possible to update a UDT parameter at runtime after the instance is created?
  • If yes, is system.tag.configure() the correct way?

Thanks in advance — any tips are welcome!

Yes, you can, with a tag change event script that monitors your query tag. But you shouldn't, as changing UDT instance parameters restarts the whole UDT, an expensive dynamic operation.

Yeah, don't do this dynamically. Make one UDT instance per machine. Do any other indirection in your user interface, not in your tag architecture.

2 Likes

Another major issue is that any tag and alarm history will be destroyed because their context will be missing..

1 Like

Thanks for the answers.
I decided to go with a different method since changing UDT parameters dynamically isn’t recommended.
I solved it by creating a dataset-type memory tag inside the UDT and writing the corresponding row of data into it using a script. Then, I used reference bindings to point to the dataset values.
No need to change UDT parameters or recreate instances.
It works well and keeps the structure stable.