Using a Dataset tag as a function definition on Shared Script

I am testing my function on the Script Console and it works:
(however if I use this code as a function on a Share Script, it doesn’t work)

stepX = 10

#this is my DataSet tag
tagValue = system.tag.read("MX_Seating/R1Cx_01B/Criticals").value

def valueIn(tagValue, stepX):
	listOfRowValues = []
	for row in range(tagValue.rowCount):
	    listOfRowValues.append(tagValue.getValueAt(row, 0))	    
	if stepX in listOfRowValues:
		print "CC"
	else:
		pass

valueIn(y,x)

The following is my definition on the Shared Script: shared.FindValue

def valueIn(tagValue, stepX):
	listOfRowValues = []
	for row in range(tagValue.rowCount):
	    listOfRowValues.append(tagValue.getValueAt(row, 0))
	if stepX in listOfRowValues:
		return "CC"
	else:
		pass

I am using a Dataset Memory tag (called "Criticals"which has one column and 4 rows as one input, and an integer Memory tag as another input (called “Value”). My goal is that if the Values is in the list of Criticals, I would just write a string on string (“CC”) on a Memory Tag.
The Dataset tag has 1 column and 4 rows with 4 values:

But, this is not working: I already tried the following:
I input this expression on a expression tag, string type:

runScript("shared.FindValue.valueIn("+{[.]Criticals}+","+{[.]Value}+")")

That didn’t work:

I also tried the following expressions on a expression tag, interger type:

if(lookup({[.]Criticals},10,-1,"StepNo"),1,0)
if(lookup({[.]Criticals},{[.]Value},-1,"StepNo"),1,0)

None of them work. Now, my assumption is that there is some modification I need to have to compensate for the fact that I am using a tag, Dataset, as my input for my function. But, I am not sure of the correct format, up to this point.
Does someone has an idea on how to make this correction?

In the global scope (ie, from an expression tag) you need to qualify your tag path:
[realtime tag provider]path/to/tag.
Most likely, the name of the realtime tag provider you’re using is just [default]. There’s no harm to qualifying tagpaths in the client scope, either, so just changing that in your shared script should be sufficient.

Thank you very much. I also have to give credit to Tyler from Inductive Automation technical support who replied me on this one. All I had to do is change the format on my expression tag to this one:

runScript("shared.FindValue.valueIn",0,{[.]DatasetTag},{[.]Value})

Basically, using the optional “args” parameter for runScript().

1 Like