Using Scripting resources within Alarm Notification Pipeline not working

I have a Script block and I’m trying to call a function defined in another Script. However, each time I call it I get:

NameError: global name 'MyScript' is not defined

Or if I try to import MyScript inside of the alarm notification block, I get the error:

ImportError: No module named MyScript

Running the latest nightly.

Sometimes the Jython instances don’t refresh/reload the imports right away.

I’ve found I can usually force a refresh if I make a trivial edit in the script in Designer then close the script and hit save.

Other things can apparently lead to this, for example reusing script file names between multiple projects.

Also maybe read the links in that thread in the paragraph starting “I tried searching around in the forum…”

Oh, also, alarm scripts run in the gateway context, not a specific project. You can only import/use script set in the “Gateway Scripting Project” from your global gateway settings.

I don’t think this is true in Ignition 8 - scripts in a notification pipeline block will run in the context of the project the pipeline is defined in, which could be his issue.

Hmm, I think I’m wrong here. Digging a little more.

update: yeah… it looks like despite pipelines belonging to a specific project now, the scriptable block was never updated to use the project script manager rather than the gateway one, which would be whatever is in the “global scripting project” setting.

1 Like

So that would mean this behavior is a bug? Or will I need to set a global scripting project in order for things to work properly?

Well… my initial reaction to this screams “bug” but if we change this behavior now we’ll break existing pipeline script blocks. I’m not sure what we’ll do about it. Maybe it will have to become a configuration option whether it’s gateway or project scope and remain defaulted to gateway.

I see! I’ll just update my global scripting project then. Thanks!