# Gateway Script global name not defined

**URL:** <https://forum.inductiveautomation.com/t/gateway-script-global-name-not-defined/14819>\
**Category:** Ignition\
**Created:** [July 18, 2017, 6:12pm UTC](https://forum.inductiveautomation.com/t/gateway-script-global-name-not-defined/14819 "2017-07-18T18:12:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 18, 2017, 6:27pm UTC](https://forum.inductiveautomation.com/t/gateway-script-global-name-not-defined/14819/2 "2017-07-18T18:27:19Z")

</div>

Yes. This is happening because there is a bug in Ignition with Gateway scripts. Gateways scripts still have the old legacy scoping enabled by default.

The bug is this: variables defined in the outermost scope can not be see by functions. In this case you have the generateReportPart variable that holds a function and you try to execute it in the generateReport function. This is perfect legal Python – but as I said the error occurs because of the scoping bug in Gateway scripts.

I wrote about the scope change in Ignition here: [http://www.perfectabstractions.com/blog/new-scripting-features-in-ignition-77-part-1#standard-scoping](http://www.perfectabstractions.com/blog/new-scripting-features-in-ignition-77-part-1#standard-scoping)

The best thing to do is write all your code in a project library function and then simply execute that function in your Gateway script.

---

_[View the full topic](https://forum.inductiveautomation.com/t/gateway-script-global-name-not-defined/14819)._
