# Tag event script is not triggring

**URL:** <https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418>\
**Category:** General Discussion\
**Tags:** ignition81, scripting\
**Created:** [December 21, 2023, 12:19pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418 "2023-12-21T12:19:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [December 21, 2023, 12:19pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/1 "2023-12-21T12:19:26Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/a/9af0784abf712efc688c72ce95adca555891fa93.png)

but the event is not triggering in the tag event value change script

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 21, 2023, 12:53pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/2 "2023-12-21T12:53:14Z")

</div>

Since that is a screen shot, something looks amiss. That `writeBlocking` line shouldn't be formatted that way. It appears as if it's been commented out.

As a side note, I would recommend not doing anything with sockets or queries in a tag value change script.

What indicates to you that this script isn't triggering?

As an aside, you should use the `system.date` functions, instead of the `datetime` module.

I would recommend doing this in a Gateway Tag Changed Script.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 21, 2023, 12:56pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/3 "2023-12-21T12:56:40Z")

</div>

This maybe missing the project name from the named query params as well if its in the gateway scope?

Are you seeing any errors in your logs when this tries to execute. That would be most helpful.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 21, 2023, 12:57pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/4 "2023-12-21T12:57:26Z")

</div>

It's in a Tag Value Changed script, so it is in Gateway Scope.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 21, 2023, 12:58pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/5 "2023-12-21T12:58:12Z")

</div>

Right that needs the project name doesn't it? Since it's the gateway scope and project agnostic

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/5691beb81875bb4706d816ef1abefdaca617f613.png)

Would expect it to be `system.db.runNamedQuery("Some Project", "ParameterSetPoint Change", params)`

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [December 21, 2023, 1:02pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/6 "2023-12-21T13:02:40Z")

</div>

> [@lrose](#):
>
> That `writeBlocking` line shouldn't be formatt

I just commented that coz I don't need it.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 21, 2023, 1:13pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/7 "2023-12-21T13:13:24Z")

</div>

If this is in a tag, it resides in the gateway, so I also suspect you wouldn't get the hostname or username.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 21, 2023, 1:20pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/8 "2023-12-21T13:20:42Z")

</div>

Please post code rather than picutres of code so we don't have to type it all out again to test or modify it.  
See here:

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Code block formatting Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code] Note that all the \</\> button does is add three backticks ``` on the line before the code block and anot…

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 22, 2023, 1:47pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/9 "2023-12-22T13:47:32Z")

</div>

> [@arpit\_yadav](#):
>
> but the event is not triggering in the tag event value change script

It is triggering, but it's also crashing. You need to go and check the logs, I'm willing to bet you'll find an `AttributeError`.  
Why ?  
Because `system.security.getUserName()` can't run there. The script executes on the gateway, because it's on a tag's value change event, and the gateway doesn't have this kind of information. You'll need a different approach.  
What are you trying to do ?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 22, 2023, 1:52pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/10 "2023-12-22T13:52:24Z")

</div>

> [@lrose](#):
>
> That `writeBlocking` line shouldn't be formatted that way. It appears as if it's been commented out.

I believe he cropped the `#` out:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f0de6249925ecf9ea09dc24bbbf12d846311e51a.png)

There are so many things going wrong with this post !  
You shouldn't post screenshots of code, but if you do... at least include the whole thing, and the line numbers if you have line numbers.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 22, 2023, 2:26pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-is-not-triggring/83418/11 "2023-12-22T14:26:35Z")

</div>

> [@pascal.fragnoud](#):
>
> I believe he cropped the `#` out:

They did, because they "don't need it"
