# Tag Event Value Changed Project Script

**URL:** <https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [June 6, 2022, 8:42pm UTC](https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426 "2022-06-06T20:42:57Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [June 6, 2022, 8:42pm UTC](https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426/1 "2022-06-06T20:42:57Z")

</div>

I have a project script (`tagHistory.logTagChange()`) that I’m attempting to call from within a tag value changed event script. When I do so, I get the error:

```auto
Error executing tag event script: Traceback (most recent call last): File "<tagevent:valueChanged>", line 2, in valueChanged NameError: global name 'tagHistory' is not defined

```

However, when I use the script console with `tagHistory.logTagChange()` and don’t fill in the args I get the expected error (function takes exactly 6 args). How do I scope the function so that the tag event script can find it?

---

<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:** [June 6, 2022, 9:10pm UTC](https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426/2 "2022-06-06T21:10:24Z")

</div>

Tag events can only call functions in the global scripting project. If you can’t put this function in that project, you will need to use a project event (gateway tag change event) instead of a tag event.

---

<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:** [June 6, 2022, 9:19pm UTC](https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426/3 "2022-06-06T21:19:12Z")

</div>

I guess that makes sense since tags are gateway objects and these scripts would be in the project scope.

If I only have one project on the gateway (the project that I’m calling the script from) can I still use it as the Gateway Scripting Project, or does it nee to be a stand alone project? (even if it may be advisable to have a standalone scripting project).

---

<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:** [June 6, 2022, 9:39pm UTC](https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426/4 "2022-06-06T21:39:57Z")

</div>

> [@amarks](#):
>
> can I still use it as the Gateway Scripting Project

Yes.

---

<div class="post-metadata">

**Author:** ![martinel3746](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@martinel3746](https://forum.inductiveautomation.com/u/martinel3746)\
**Post date:** [June 6, 2022, 10:04pm UTC](https://forum.inductiveautomation.com/t/tag-event-value-changed-project-script/60426/5 "2022-06-06T22:04:21Z")

</div>

Config → Gateway Settings → Gateway Scripting Project
