# Call global script from UDT tag value change event

**URL:** <https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385>\
**Category:** Ignition\
**Created:** [October 25, 2018, 9:50pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385 "2018-10-25T21:50:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 25, 2018, 9:50pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385/1 "2018-10-25T21:50:14Z")

</div>

Hi all,

Trying to work out the best way to handle some scripting…

I have a UDT for an AB Logix PLC, which handles diagnostic information and also has date and time information from the PLC in it. This tag structure also has the ability to store a new date and time, and then send it back to the PLC to set the PLC time. This UDT structure is all working well.

Next, I have a script which is currently stored in the project script library. I pass it a tag path to one of those UDT instances, and it gets the current PC time and synchronises the target PLC clock with that PC time. I can call this script using a button on a client, which works just fine.

But here’s where my current approach doesn’t work. Within the UDT, I’ve got a bool tag called “AutoSyncEnable”, and two int tags “AutoSyncHour” and “AutoSyncMinute”. The idea is that if Auto Sync is enabled, it will automatically sync the PLC time at [AutoSyncHour]:[AutoSyncMinute] every day. To trigger this, I have a tag change event on the CurrentMinute tag - so every time the PLC clock’s minute changes, I will check if Auto Sync is enabled, and if so, whether it’s the right time to do the Auto Sync. If it is, I call the same script as before. However, I’ve learned that I can’t call a project library script from a UDT tag value change event.

I could just duplicate the script right there in the UDT definition, as it’s only writing to other tags within that UDT anyway - but as soon as I find myself copying and pasting a script, I start to think that maybe I should be doing this differently. Any suggestions?

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [October 25, 2018, 10:29pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385/2 "2018-10-25T22:29:52Z")

</div>

See discussion here about this related topic:

[Error Running Project Script: “project not defined”](http://forum.inductiveautomation.com/t/error-running-project-script-project-not-defined/20272)

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 25, 2018, 10:49pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385/3 "2018-10-25T22:49:24Z")

</div>

Thanks. Solution (as found in that link) was to move the script to a shared script, not a project script. This makes a lot of sense anyway, as this is a very generic script that will ultimately be used on every PLC that’s added to the system

---

<div class="post-metadata">

**Author:** ![tony.petruzzi](https://avatars.discourse-cdn.com/v4/letter/t/e47c2d/32.png) [@tony.petruzzi](https://forum.inductiveautomation.com/u/tony.petruzzi)\
**Post date:** [August 4, 2021, 4:25pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385/4 "2021-08-04T16:25:34Z")

</div>

Excuse my ignorance, but what is a Shared Script?

---

<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:** [August 4, 2021, 4:44pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385/5 "2021-08-04T16:44:57Z")

</div>

In v7.9, tag events are “outside” any project and can only use scripts in the “shared” namespace. This architecture was changed in v8.x to the “Global Scripting Project”. In v8.x, all scripts are in projects, with a designated project serving non-project elements (tags).

---

<div class="post-metadata">

**Author:** ![tony.petruzzi](https://avatars.discourse-cdn.com/v4/letter/t/e47c2d/32.png) [@tony.petruzzi](https://forum.inductiveautomation.com/u/tony.petruzzi)\
**Post date:** [August 4, 2021, 6:48pm UTC](https://forum.inductiveautomation.com/t/call-global-script-from-udt-tag-value-change-event/20385/6 "2021-08-04T18:48:54Z")

</div>

Thank you but I found my answer.

[https://docs.inductiveautomation.com/display/DOC81/7.9+to+8.1+Upgrade+Guide](https://docs.inductiveautomation.com/display/DOC81/7.9+to+8.1+Upgrade+Guide)

look at “Project Inheritance & “Global” Upgrade Logic”

A Shared Script was a script that was written in the “global” project in 7.9 which all projects inherited from directly. in 8.x this was changed so that projects must explicitly specify their parent project for inheritance. In order not to break projects being upgrade from 7.9 to 8.x, a project called “global” was created during the upgrade and all existing projects would have that set as their parent.
