# Run a shared script on a tag event?

**URL:** <https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657>\
**Category:** General Discussion\
**Created:** [November 8, 2018, 7:06am UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657 "2018-11-08T07:06:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [November 8, 2018, 7:06am UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/1 "2018-11-08T07:06:35Z")

</div>

I just have a question,  
I have a hunch that this is not possible, but I am going to ask anyways.  
Can I run a shared script on a tag event? Because what I am trying is not working so far.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/ff32e957b2a7a7391010e9fd42c60411bd500ec3.png)

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [November 8, 2018, 7:21am UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/2 "2018-11-08T07:21:22Z")

</div>

Yes, you can call a global script from a tag value change event script. I noticed your global script was changed but not saved (italics in module name). Could you try saving and then testing again?

---

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [November 8, 2018, 7:44am UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/3 "2018-11-08T07:44:18Z")

</div>

Thank you.  
Now, I saved it and test it again but when I toggle the tag, it show red indicating the script is not executing.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/6f77d6dc556ff2ac97370916c8dbad4e4c21c0f4.png)

---

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [November 8, 2018, 7:45am UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/4 "2018-11-08T07:45:16Z")

</div>

I test this function script on the Script console, but it only works for me on the Script console so far 😕

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 8, 2018, 12:32pm UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/5 "2018-11-08T12:32:48Z")

</div>

Right click on the tag showing the red error and choose Diagnostics.  
Then drill down into the tree until you get to the error.

---

<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:** [November 8, 2018, 1:54pm UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/6 "2018-11-08T13:54:55Z")

</div>

> [@Lalillo1](#):
>
> I test this function script on the Script console, but it only works for me on the Script console so far

A lot of functions work differently in gateway scope, especially anything that depends on project defaults. Tag Events aren't in a project, so everything must be declared. All of your tag paths must have the bracketed provider name or one of the provider shortcuts, as one example.

---

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [November 9, 2018, 12:49am UTC](https://forum.inductiveautomation.com/t/run-a-shared-script-on-a-tag-event/20657/7 "2018-11-09T00:49:01Z")

</div>

You are correct. Thank you very much.  
On a expression tag this worked:

```auto
runScript("shared.Write.BuildIns",0,"[default]R3_03_S1/Ins","[default]R3_03_S1/Arg","[default]R3_03_S2/Desc","[default]MX_Seating/R1Cx_01B/CriticalsX")

```

On a tag event:

```auto
	if currentValue.value == 1:
		shared.Write.BuildIns("[default]R3_03_S1/Ins","[default]R3_03_S1/Arg","[default]R3_03_S2/Desc","[default]MX_Seating/R1Cx_01B/CriticalsX")
	else:
		pass

```
