I am trying to create a dataset-expression type tag that uses an expression to create its dataset. I have created a script that will return a dataset but when I am binding the value of the tag to this script using the following expression:

runScript("database.getRoleCredentials", 10, "Operator")


I continually keep getting error_expressionEval. I have included the script in the global project based on previous forum discussions ( runScript in expression tag - Ignition - Inductive Automation Forum)
and also run the script on script console. It runs fine on script console where the end product is a dataset, but I can not figure out why the expression on the dataset keeps throwing the error_expressionEva error. Can someone please help me with this?

You'll have to show your script. Also, look in the gateway logs for related errors.

You may need to use try: - except: clauses in your script to catch and log errors.

Hi Pturmel, thanks for replying. I am pasting my script below:

logger = system.util.getLogger(''+__name__)

def getRoleCredentials(word): 
		headers = ["Rolename", "Security Zone", "Access"]
		data = []"[MVNT]_dataset_users").value"[MVNT]_dataset_ipadresses").value
		chk1 = 0
		chk2 = 0"[System]Client/Network/IPAddress").value
		row_n = ip_addresses.getRowCount()
		for r in range(ip_addresses.getRowCount()):
			ip_add = ip_addresses.getValueAt(r,1)
			if (ip_add != "" and logged_ip == ip_add):
				chk1 = 1
			elif (ip_add == ""):
				chk2 = chk2 +1
        #ROLE CHECK

		for r in range(usr_roles.getRowCount()):
			role = usr_roles.getValueAt(r,0) 
			if (role != ""):
				chk = usr_roles.getValueAt(r,1)
				if role in
					if word in chk:
						if (chk1==1):
							data.append([role, "", "Read_Write"])
							data.append([role, "", ""])
						data.append([role, "", ""])
					data.append([word, "", ""]) 
				if (chk1==1):
					data.append([word, "", "Read_Write"])
					data.append([word, "", ""])
		sec_data = system.dataset.toDataSet(headers, data)
		return sec_data
	except AttributeError:

{ Please edit your comment, highlight all of the pasted code, then click the "preformatted text" button in the comment editor. This will make a proper code block for us, instead of the mismash currently shown. }

Hi, I just edited my reply containing code with the correct format. Please let me know if this looks good now


I don't see anything obviously wrong with your script but just check - running getRoleCredentials("Operator") in script console works or does it throw some error?

it works great on the script console, returns a dataset

Sanity check - is the "global" project this is defined in also configured as the Gateway Scripting Project in the gateway settings?

1 Like

This is your problem. That hierarchy doesn't exist in gateway scope (nor Perspective scope). You should not expect an expression tag to be able to use any information specific to user interfaces.


Side note:

This construct, if activated, guarantees you won't get a log entry and you will get a NULL returned to the tag.

yeah I double checked this before based on that post

Phil spotted your issue. You can't reference Vision Client tags from gateway scope.

except AttributeError:
		test ="[MVNT]_dataset_users").value
		return test

will this edit help?

When you catch errors in gateway scope, you should be logging the error details. Whether that is an appropriate return value is moot, as you are attempting to do something in gateway scope that is simply not possible. Gateway scope doesn't have client information.

1 Like