# Call function from script library in gateway event scripts

**URL:** <https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696>\
**Category:** Ignition\
**Created:** [February 20, 2017, 7:39am UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696 "2017-02-20T07:39:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![StepanenkoPaul](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StepanenkoPaul](https://forum.inductiveautomation.com/u/StepanenkoPaul)\
**Post date:** [February 20, 2017, 7:39am UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696/1 "2017-02-20T07:39:58Z")

</div>

Maybe somebody knows how i can call function from script library in gateway event scripts?  
Example i have script “myfuncs” with function “myFunction”. I have tryed call function in this way:

project.myfuncs.myFunction()

but nothing happened.

Function has worked in script console.

---

<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:** [February 20, 2017, 1:00pm UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696/2 "2017-02-20T13:00:56Z")

</div>

It depends on where your event script is placed. If it is a tag event, you can’t use ‘project._’ scripts. You can only use 'shared._’ scripts. Tags aren’t part of a project, so no project resources are available. If you need to trigger on tag changes in a project context, use the project’s event scripts. Same sort of thing applies to any of the global events.

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [February 21, 2017, 7:54pm UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696/3 "2017-02-21T19:54:53Z")

</div>

Gateway scripts can’t access project resources, so you’ll have to make sure your scripts are stored in Global / Script Library (shared). In your gateway event script, call your script using `shared.myfuncs.myFunction()`

---

<div class="post-metadata">

**Author:** ![ingraham](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@ingraham](https://forum.inductiveautomation.com/u/ingraham)\
**Post date:** [January 11, 2019, 9:12pm UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696/4 "2019-01-11T21:12:56Z")

</div>

I’m calling a project script from a Gateway Event Script. Now I’m confused as to why that’s working. But it’s definitely working. Perhaps I’m misunderstanding the question or the terminology? Under “Project”, there is a section called “Scripts.” Underneath it are “Script Library [project]”, “Client Event Scripts”, and “Gateway Event Scripts.” I’ve added a timer event in the Gateway Even Scripts. It calls project.my\_funcs.my\_func() with no issues. Under “Global” I have a “Script Library [shared]” but no “Gateway Event Scripts [shared]” or similar. I have no shared scripts at all, so I know I’m not accidentally calling the wrong thing. So what am I missing here? Using version 7.9.9

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 11, 2019, 9:21pm UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696/5 "2019-01-11T21:21:29Z")

</div>

> [@ingraham](#):
>
> I’ve added a timer event in the Gateway Even Scripts

These belong to a project. They aren't the same thing as a tag change script that is defined _on_ a tag.

---

<div class="post-metadata">

**Author:** ![Dhruvil\_Patel](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Dhruvil\_Patel](https://forum.inductiveautomation.com/u/Dhruvil_Patel)\
**Post date:** [May 26, 2023, 7:52pm UTC](https://forum.inductiveautomation.com/t/call-function-from-script-library-in-gateway-event-scripts/12696/6 "2023-05-26T19:52:06Z")

</div>

I am able to access this library from script console. But If I use it in Gateway Tag change event, It gives me an error.

## Code

from pyepc import decode  
##Code

##Error  
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 1, in File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\pyepc\ __init_\_.py", line 1, in from .epc import SGTIN, SSCC, decode # noqa File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\pyepc\epc.py", line 9, in from . import utils File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\pyepc\utils.py", line 11, in import requests File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\requests\__ init_\_.py", line 45, in from .exceptions import RequestsDependencyWarning File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\requests\exceptions.py", line 9, in from urllib3.exceptions import HTTPError as BaseHTTPError File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\requests\compat.py", line 42, in if is\_py2: ImportError: cannot import name JSONDecodeError

##Error
