# Using a Dataset tag as a function definition on Shared Script

**URL:** <https://forum.inductiveautomation.com/t/using-a-dataset-tag-as-a-function-definition-on-shared-script/19825>\
**Category:** General Discussion\
**Created:** [September 26, 2018, 2:52am UTC](https://forum.inductiveautomation.com/t/using-a-dataset-tag-as-a-function-definition-on-shared-script/19825 "2018-09-26T02:52:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [September 26, 2018, 2:52am UTC](https://forum.inductiveautomation.com/t/using-a-dataset-tag-as-a-function-definition-on-shared-script/19825/1 "2018-09-26T02:52:06Z")

</div>

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)  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a16799c11735e438af72dd47c7485bc40939bc01.png)

```auto
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_

```auto
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:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/93e45a689c48342f0bbed0ad847036fb03fdacea.png)

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

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

```

That didn’t work:

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

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

```

```auto
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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 26, 2018, 3:41pm UTC](https://forum.inductiveautomation.com/t/using-a-dataset-tag-as-a-function-definition-on-shared-script/19825/2 "2018-09-26T15:41:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [September 27, 2018, 1:47am UTC](https://forum.inductiveautomation.com/t/using-a-dataset-tag-as-a-function-definition-on-shared-script/19825/3 "2018-09-27T01:47:33Z")

</div>

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().
