# Run Tag Event Script from Button Press (Gateway and Project Scope)

**URL:** <https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [November 28, 2022, 6:06pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990 "2022-11-28T18:06:54Z")\
**Posts on this page:** 7\
**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:** [November 28, 2022, 6:06pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/1 "2022-11-28T18:06:54Z")

</div>

I would like to put a button on the screen to manually fire the script that typically runs automatically based on a tag event.

Is there a way to manually call the tag event script directly from the tag?

Or, will I have to more-or-less copy paste and make adjustments for calling from the button script instead of the tag 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:** [November 28, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/2 "2022-11-28T18:08:04Z")

</div>

Place the script in a Script Library, then you can call it from both the Tag Event and a Button press.

---

<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:** [November 28, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/3 "2022-11-28T18:08:56Z")

</div>

I have the script in the library, but there are properties of the tag that I need to pass to the 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:** [November 28, 2022, 6:14pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/4 "2022-11-28T18:14:28Z")

</div>

You can read tag properties from a tag using

```auto
system.tag.readBlocking(['path/to/tag.property1Name','path/to/tag.property2Name'])

```

---

<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:** [November 28, 2022, 6:26pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/5 "2022-11-28T18:26:35Z")

</div>

This project script calls a named query. Typically, it's from the gateway scope, so my named query call has extra parameters when calling from the button press (project/client) scope that is causing errors.

Any way to avoid this without adding an extra parameter to my project script?

I decided to just add an optional parameter to my project script, since that's the easiest solution. Default "clientScope" variable to 0 (false), and it can be provided as true when needed to call from the project scope.

---

<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:** [November 28, 2022, 6:34pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/6 "2022-11-28T18:34:07Z")

</div>

> [@amarks](#):
>
> I decided to just add an optional parameter to my project script, since that's the easiest solution. Default "clientScope" variable to 0 (false), and it can be provided as true when needed to call from the project scope.

This is the only way that I know of.

---

<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 28, 2022, 6:44pm UTC](https://forum.inductiveautomation.com/t/run-tag-event-script-from-button-press-gateway-and-project-scope/66990/7 "2022-11-28T18:44:15Z")

</div>

You can also use `system.util.sendMessage` to the gateway and let the gateway message handler call the library script. It will then be in gateway scope all of the time.
