# Gatway tag change script, getting id from db best practice

**URL:** <https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677>\
**Category:** Ignition\
**Tags:** database, scripting, perspective\
**Created:** [May 23, 2026, 4:09pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677 "2026-05-23T16:09:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 23, 2026, 4:09pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677/1 "2026-05-23T16:09:27Z")

</div>

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!

---

<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:** [May 23, 2026, 5:27pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677/2 "2026-05-23T17:27:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 23, 2026, 5:57pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677/3 "2026-05-23T17:57:37Z")

</div>

I didn't know that was an option, thanks

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 23, 2026, 7:26pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677/4 "2026-05-23T19:26:01Z")

</div>

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

---

<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:** [May 23, 2026, 7:44pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677/5 "2026-05-23T19:44:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [May 23, 2026, 7:55pm UTC](https://forum.inductiveautomation.com/t/gatway-tag-change-script-getting-id-from-db-best-practice/115677/6 "2026-05-23T19:55:57Z")

</div>

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