# Gateway Tag Change Script Function Call Weird

**URL:** <https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058>\
**Category:** Ignition\
**Created:** [November 9, 2025, 5:21pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058 "2025-11-09T17:21:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 9, 2025, 5:21pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058/1 "2025-11-09T17:21:11Z")

</div>

Weird! Function cannot see other Functions.  
WHAT IS GOING ON?

I have the following code:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/0/e07d16533de3a78355d6e08b9a53da7a853883c1.png)

ERROR:

```python
line 6, in function2 NameError: global name 'function1' is not defined

line 9, in function3 NameError: global name 'event' is not defined

line 12, in function4 NameError: global name 'system' is not defined

```

why oh why?!

---

<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 9, 2025, 5:29pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058/2 "2025-11-09T17:29:16Z")

</div>

Legacy scoping issue.

Do not use `def` inside gateway event scripts. In my not-so-humble opinion, you should not use `def` (or `import`) in _ **any** _ event script. Make a one-line call to a project library script, passing any necessary arguments in the function call. _ **Always.** _

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 9, 2025, 5:36pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058/3 "2025-11-09T17:36:17Z")

</div>

> [@pturmel](#):
>
> Do not use `def` inside gateway event scripts.

Lol, my bad.

[quote="pturmel, post:2, topic:112058"]  
Make a one-line call to a project library script,  
[/quote]

me, wanting to skip the explanation why I have such script in project library to team lead, and skip the decision of a proper place to store it in Project Library.

THANKs for fast response.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 10, 2025, 5:31pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058/4 "2025-11-10T17:31:52Z")

</div>

For posterity (I know Phil knows this, but for the OP and anyone who comes across this thread in the future) - that legacy scoping issue is fixed in 8.3.0 and up.

---

<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 10, 2025, 5:57pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-script-function-call-weird/112058/5 "2025-11-10T17:57:50Z")

</div>

> [@paul-griffith](#):
>
> scoping issue is fixed in 8.3.0

Indeed, but there are performance reasons for my one-liner event advice, too. I will continue harping on it.
