Help using runScript in Expression Tag

I believe I’m following the examples in the manual correctly but I cant even get a simple example like the one depicted in the picture below to work.

I have created a very simple script file called test. Within it, I have created a Function called testFunc that, when executed, returns “test”. I started out with more complex Function to which I was trying to pass arguments from the runScript expression, but when that failed, I tried dumbing things down until it worked. This is as dumb as I can get it and I still cant get it to work. I’m hoping/assuming this is something very simple I’m overlooking. Hoping one of you can point out my error.

Thanks in advance.

image

Try removing the space after TestFunc and the first parentheses in the script.

Thanks for the recommendation but removing the space did not resolve the issue.

Can you show us your tag definition?

Tag event scripts and expressions can only run scripts from the Gateway Scripting Project. Is this specified in the Gateway settings?
Project Library - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

2 Likes

BINGO!! Thanks! As I read your comment this quickly came back to me as a constraint. I spent hours on this yesterday thinking it was something in my script, or the way in which I was calling my script.

Not sure if anyone from the Ignition Team will see this but it would be helpful if a note were added to the runScript section of the manual noting this constraint. Scripts can only be executed if the are scoped by the Gateway scripting Project. I’m sure this is an Ignition “101” thing but it sure tripped me up.

This has caught me many times.

There is a nuance: if the runScript is in a Perspective project and the script is in that project too, I think it will run. Anything to do with tags, i.e. tag event scripts and tag expressions, require the gateway scripting project as tags do not belong to a project.

Just to add, @deon.korb is correct. If you use runScript from a session scope (for example, in a component’s expression binding) it can run project scripts. However, your point stands, there is a section in the manual Calling runScript in Tags but does not mention it requiring Gateway scoped scripting :sweat_smile:

I think we can all agree it is still confusing though :sweat_smile: (fallen into the trap many times, and still do).