runScript in expression tag

I tried to put in an expression tag RUNSCRIPT but not working.
I enclose a photo.

the error is this:

Last Error Cause com.inductiveautomation.ignition.common.expressions.ExpressionException: Error executing script for runScript() expression:project.test.getTempAt(‘95818’) ERROR


Expression tags only have access to the shared script namespace, as they are visible to all projects. Move your module from “project.” to “shared.”

1 Like

It works for me, but I have the script in the global “shared” namespace. I think since it’s in your project namespace the tag doesn’t know which project to look at, since tags are global. Move the script to the global shared area and try it again.

One clarification: runScript() in a client expression tag does have access to the “project.” namespace. All other tags can only use the “shared.” namespace. (Along with the built-in stuff.)

Good morning,
I have a analog problem

my code is this

def CheckUserRoleState(State):
retValue = False
definedRoles =

# ciclo per tutti i ruoli da controllare passati
for role in definedRoles:
	if left(role, 2)== 'EU' and substring(role, 3,5)== 'State' 
		retValue = True

return retValue

Somebody can explain me how use script function in expression for visible/enable property of object ?


Expression tags (in the gateway) do not belong to a project, so can only call shared.* scripts.

I have try to do how suggested


but nothing change…

how can find some example of how use expression with script?


Oh, and the gateway doesn’t have a user or roles – won’t work. That’s only meaningful at a client. If it must be a tag, it’ll have to be a client tag. And client tags can call project scripts, so you don’t need to make it shared.

Ok now script run but i have this type of error

Caused by: Traceback (most recent call last):
File “expression:runScript”, line 1, in
SyntaxError: (“mismatched input ‘\n’ expecting COLON”, (‘module:project.Utility’, 38, 60, “\t\tif left(role, 2)== ‘EU’ #and substring(role, 3,5)== State \n”))

and i have use

You are missing a colon from a few posts back.

# ciclo per tutti i ruoli da controllare passati
for role in definedRoles:
	if left(role, 2)== 'EU' and substring(role, 3,5)== 'State':
		retValue = True

return retValue

I added it at the end of line 3

Question: command like left need to be declared?

Yes, you should use python slicing

Thanks :slight_smile:

I am encountering the same problem in 7.9.9

I created a shared script with a method that accepts three parameters. Two strings and a number. So something like
The method calculates an end date as now(), a start date as 15 seconds earlier, then calls system.tag.queryTagCalculations where the parameters are used to calculate the tag name, and Average is returned.
The last statement in the method is result.getValue(0,1) to get the float value

When I link this to a button in my project it works
When I link it to a tag using runScript(“shared.script_a.calc_method(‘0’,‘middle’,15)”), there are no errors but the result is always null.
Ultimately I want to use this in an alarm, but I can always alarm on the expression tag.

I can’t see any errors in the log. Any ideas?

Hi, I have an error in a simple runScript in expression tag, and it is located in shared scripts.
The error message doesn´t indicate too much. Attached you Will find the images.
This is in ignition 8. Any suggestions?
thank you!

I see that you are in Ignition 8 instead of the original posts which are in 7.9. There is no longer the “Global” project that you are familiar with in 7.9. Instead, tags have access to scripts that are in the Gateway Scripting Project. This is configured on the gateway web page Config > Gateway Settings > Gateway Scripting Project.
At this point, the script you want to access in the tag HAS to be on that project. Tags cannot run scripts from another project that inherits that project. From your pictures, it looks like maybe you have upgraded from 7.9 and that’s why you have a folder named “shared” which is fine, but if you upgraded from 7.9 chances are your Gateway Scripting Project is going to be Global and therefore the script has to be in the project named Global.


Thank you osolorzano, I followed your advice and it worked perfectly!
you are right, this Gateway was loaded from Ignition 7.9, and it created automatically the Gateway Scripting Project with the name Global.
Thank you.

In 7.9.9, my shared script below doesn’t work in a runScript expression tag. On the contrary it works in a label component.

def getDbName():
	dbname=str(system.db.runQuery("SELECT DATABASE()")[0][0])
	return dbname




Tags don’t have a default database, because they aren’t in a project. You must specify the database connection name in runQuery(). See its docs.