Running Library Script from Designer Script Console

I have a project set as the gateway scripting project and the script executes no problem from the designer of that project.

However, I open the script console in the designer on a different project on the same gateway and it says the function is not defined.

Is this because the script is running in the designer/client scope of the 2nd project?

If so, can I test these scripts in gateway scope outside of the scripting project?

Is the script you're trying to run new, and if so, did you save it and then merge changes in the other project?

It’s been saved. Changes have been merged, gateway has been restarted. The gateway scripting project is set correctly

I sometimes cheat and put a gateway tag change event in that calls the script, assign it to a temporary boolean memory tag then just toggle the tag to run it.

1 Like

So yes, the issue is that it’s running in the designer scope?

I assume so, I have not had a chance to replicate and test the idea.

The 'Gateway Scripting Project' setting is totally orthogonal to the question of which scripts are 'visible' when you're in the script console.

Tree Grandparent Grandparent Parent Parent Grandparent->Parent Aunt Aunt Grandparent->Aunt Child1 Child 1 Parent->Child1 Child2 Child 2 Parent->Child2 Child3 Child 3 Aunt->Child3 Child4 Child 4 Aunt->Child4

If you open child 1 in the designer, you'll be able to use the project library of child 1, which will include any project library scripts defined in parent and grandparent, because project inheritance delivers you a "flattened" representation of parent project's resources as if they existed in your own project. You will not be able to use aunt's resources, because they are invisible to you.

The gateway scripting project could be any of those projects. All the gateway scripting project setting affects is which project's scripts you are able to use in gateway contexts that are not associated with a project. In other words - in the runScript function in expression tags. Lots of other ways to author expressions run on the gateway (Perspective, Reporting, Alarm Pipelines, SFCs, etc) - but all of those are associated with a project, and therefore naturally participate in project inheritance and pay no attention to the gateway scripting project.

Restated again - if the gateway scripting project is child 3, you're able to use scripts from child 3, aunt, and grandparent in your expression tags' runScript expressions.

4 Likes

And in case anyone reads this as a definitive list, it also includes other gateway scoped places like tag value change events

3 Likes

Ultimately, I’m trying to get this script to run in a notification pipeline on the 2nd project. Does that script not execute in gateway scope? In my logs it says that the library is undefined.

Yes, but gateway scope ≠ gateway scripting project. The GSP is just one small piece of gateway scope.

*Cough* Share more details, like actual project names and inheritance, and the GSP name.

Alarm pipelines are defined in project configuration. Whatever is attached to a project will not care what project you've set as your GSP. The same applies for example to gw script events like timers and scheduled events which are both attached to a project, despite all running in the gateway.
Tags on the other hand are not attached to projects and therefore need to know what project to use for a script library, as script libraries are project resources

2 Likes