# Button onClick event NameError when calling script from script library

**URL:** <https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [June 27, 2025, 6:06pm UTC](https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892 "2025-06-27T18:06:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Hymer](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jon\_Hymer](https://forum.inductiveautomation.com/u/Jon_Hymer)\
**Post date:** [June 27, 2025, 6:06pm UTC](https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892/1 "2025-06-27T18:06:36Z")

</div>

I have a global script library setup. I can call the scripts from it fine in tag change events and SFC from other projects. I am using the onClick Script action for a Perspective button, but when I try to call a script from the Script Library Project named NH-ScriptLibrary, I get an error.

`Error running action 'dom.onClick' on P70X RD AUTO@D/root/Button: Traceback (most recent call last): File "<function:runAction>", line 35, in runAction NameError: global name 'plexAPI' is not defined`

The code is

```python
	response = plexAPI.setJob(checkJob, workcenterKey)

```

plexAPI is the name of the script in the Project NH-ScriptLibrary that is set as the Gateway Scripting Project.

I tried using the Project name, but the get "NameError: global name 'NH' is not defined".

I could be wrong, but it seems like in this scope it does not like the '-' in the project name. Or I am just missing something obvious.

Thanks,

Jon

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [June 27, 2025, 6:21pm UTC](https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892/2 "2025-06-27T18:21:18Z")

</div>

I would assume the `-` is not a valid character for a package name as it is a reserved character in python.

The error is likely being generated by the `NH` being interpreted as a variable name in some sort of subtraction operation.

I would switch the hypen out for an underscore in the package name and try it out.

---

<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:** [June 27, 2025, 8:32pm UTC](https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892/3 "2025-06-27T20:32:31Z")

</div>

> [@Jon\_Hymer](#):
>
> the Gateway Scripting Project

The gateway scripting project setting is not relevant when you're using a script from anywhere associated with a particular project (which is basically everywhere _except_ for a tag). In that case, you're going to get your local project's script library (including any parent project(s)). You **cannot** reference library scripts in another project; you can only use those that are part of your inheritance tree.

Thus, it's usually a good idea for shared logic to have a "base" project that purely defines library scripts and truly global things, and inherit from that in all your other projects.

---

<div class="post-metadata">

**Author:** ![Jon\_Hymer](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jon\_Hymer](https://forum.inductiveautomation.com/u/Jon_Hymer)\
**Post date:** [June 30, 2025, 3:22pm UTC](https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892/4 "2025-06-30T15:22:53Z")

</div>

Thanks. I will have to reconfigure some things.

I would be nice to be able to have all my scripts in one place and just have others use them. They are wanting to have the scripts and the API keys in a project that is protected and only certain people can modify or view. But would like for others to be able to use the scripts.

Thanks,

---

<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:** [June 30, 2025, 3:35pm UTC](https://forum.inductiveautomation.com/t/button-onclick-event-nameerror-when-calling-script-from-script-library/107892/5 "2025-06-30T15:35:56Z")

</div>

> [@Jon\_Hymer](#):
>
> in a project that is protected and only certain people can modify or view

This is not possible. You can apply some guardrails to projects, but any person with **any** designer access to a gateway can use scripting to access everything in the gateway, including everything the gateway can reach in the filesystem.

If an untrusted individual needs to work on a project, you **must** use a separate dev gateway where the secrets are not present. (Presumably, a different set of test credentials would be present.) The work product would need to be deployed to the sensitive server by a **trusted** individual.

There is no alternative. (No, the new secrets management in v8.3 won't fix this case.)
