Gatway tag change script, getting id from db best practice

I have a bunch of variable names in a database by id, then I read the database and create the tags in a folder. no udt, its just singular values, they only change once a week so not high frequency of change.

I have a tag change script watching the folder and when a variable changes, I insert the value into a table. The tags are created by name with no reference to the id in the table.

I wanted to insert the id and value to reference back to the variable table and I am trying to figuire out the best practice way to achieve this.

I was thinking of maybe creating a UDT with both the value and ID but that still involves me reading another tag when the tag change script executes.

I also though of maybe appending the id (_1, _2, etc..) at the end of the name and then I could read it from the tag name when the tag change script executes.

Any other suggestions or better ways than what I am thinking? thanks!

At the time you create the variables by reading from the ID, store the ID in a custom property of the tag. Then your tag change event can read the ID from the custom property.

I didn't know that was an option, thanks

How do I access the custom property from the gateway tag change script? I tried going through event, newValue, getproperty, etc... I'm sure this is right in front of me too.

I just ended up readBlocking the path, I was hoping to access it directly from the tag that called it if possible but this is fine too. Thanks

system.tag.readBlocking() using the event's tag path and appending .somePropName.

Thanks, that's what i ended up doing. I was hoping it would come along in the event without doing an extra readBlocking.