# Passing dataset tags to a defined function in the project library

**URL:** <https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [February 21, 2024, 3:41pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107 "2024-02-21T15:41:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdelrahman\_Bahgat](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Abdelrahman\_Bahgat](https://forum.inductiveautomation.com/u/Abdelrahman_Bahgat)\
**Post date:** [February 21, 2024, 3:41pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/1 "2024-02-21T15:41:56Z")

</div>

I have two tags with datatype Dataset and a function to compare the value of a column exists in both of them. but i can't pass the two tags to the functions as a dataset they are passed as string.

what should i do?

 ![Function](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cdade7d859565c53311960858742f95981701ff1.png)  
 ![TagChangeScript](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ed587cd6f38aad9dc47a04f34efaeb1accd096f5.png)  
 ![error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/29708376bad4825a7069d683efe0ab352982f95c.png)

---

<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:** [February 21, 2024, 3:43pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/2 "2024-02-21T15:43:35Z")

</div>

You need to call system.tag.readBlocking to actually... Read the tag values 🙂  
Otherwise, you're just dealing with a literal string.

---

<div class="post-metadata">

**Author:** ![Abdelrahman\_Bahgat](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Abdelrahman\_Bahgat](https://forum.inductiveautomation.com/u/Abdelrahman_Bahgat)\
**Post date:** [February 21, 2024, 4:13pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/3 "2024-02-21T16:13:51Z")

</div>

thank you.  
I did it but this error appears. I can't use dataset functions in the project script library right?  
 ![err](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/24ee293de8ac3420edd6e8a6e66bc4aed3ae5b03.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 21, 2024, 4:22pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/4 "2024-02-21T16:22:31Z")

</div>

Something is not the type your program is expecting.

This error does not line up with any of the code that you have previously shown. Show the code as it is now, in a preformatted text block. Also, would be nice to know how these two tags are configured, and what the data in their value looks like.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 21, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/5 "2024-02-21T16:46:07Z")

</div>

> [@Abdelrahman\_Bahgat](#):
>
> I can't use dataset functions in the project script library right?

Wrong. Your error indicates you tried to use a dataset method on an object that is an ArrayList, not a dataset.

---

<div class="post-metadata">

**Author:** ![Abdelrahman\_Bahgat](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Abdelrahman\_Bahgat](https://forum.inductiveautomation.com/u/Abdelrahman_Bahgat)\
**Post date:** [February 21, 2024, 4:56pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/6 "2024-02-21T16:56:19Z")

</div>

the two tags I'm using are:

BOMList : Query tag (Dataset [20R_5C]) data is queried from the database  
BookedMaterialList : Memory tag (Dataset [23R_6C]) operator is entering the data manually.

```auto
def datasets(dataset1, dataset2):
    
    colindex= dataset1.getColumnIndex("MaterialID")
    product_ids = dataset1.getColumnAsList(colindex)

    for row in dataset2.getRowCount():
      	product_id = BOM.getValueAt(row, "MaterialID")
        		    
       	if product_id in product_ids:
       		upadate = {"Validated":1}
       		system.dataset.updateRow(dataset2, row, update)
       	else:
      		update = {"Validated":0}
       		system.dataset.updateRow(dataset2, row, update)
    	
    return dataset2

```

 ![12](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8c89dff60aca806d594f3ba0c5f62052fe0f4741.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 21, 2024, 5:08pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/7 "2024-02-21T17:08:10Z")

</div>

You're sending a List of qualified values, not the dataset. Thus the error. To properly get the value you need something like:

```auto
value = system.tag.readBlocking(listOfTagPaths)[indexOfPath].value

```

Your value change event should be:

```auto
datasets = [qv.value for qv in system.tag.readBlocking(['[.]BOMList','[.]BookedMaterialList'])]

compare.datasets(datasets[0],datasets[1])

```

Although, I will say this isn't the best way to approach this. As Phil would say "The dragons are circling".

---

<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:** [February 21, 2024, 5:12pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/8 "2024-02-21T17:12:38Z")

</div>

> [@Abdelrahman\_Bahgat](#):
>
> _Memory tag (Dataset [23R_6C]) operator

Tags are global - what happens if two operators are attempting to update the booked material list at the same time?

I wouldn't expect a library method named `compare.datasets` to require a specific input shape of dataset, either; should probably have a more useful name.

> [@lrose](#):
>
> Your value change event should be:

Nit: I like unpacking for situations like this:

```python
bomList, bookedList = [qv.value for qv in system.tag.readBlocking(['[.]BOMList','[.]BookedMaterialList'])]

compare.datasets(bomList, bookedList)

```

---

<div class="post-metadata">

**Author:** ![Abdelrahman\_Bahgat](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Abdelrahman\_Bahgat](https://forum.inductiveautomation.com/u/Abdelrahman_Bahgat)\
**Post date:** [February 21, 2024, 5:40pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/9 "2024-02-21T17:40:57Z")

</div>

If two clients are trying to update the list, I think both actions will be taken, but we are already checking if the entry is validated before starting the process.  
Is there a way to use client tags in perspective?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 21, 2024, 5:41pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/10 "2024-02-21T17:41:37Z")

</div>

> [@Abdelrahman\_Bahgat](#):
>
> use client tags in perspective?

No, but Perspective's session custom properties serve the same purpose.

---

<div class="post-metadata">

**Author:** ![Abdelrahman\_Bahgat](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Abdelrahman\_Bahgat](https://forum.inductiveautomation.com/u/Abdelrahman_Bahgat)\
**Post date:** [February 21, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-tags-to-a-defined-function-in-the-project-library/86107/11 "2024-02-21T17:51:47Z")

</div>

Thanks all for your help, I really appreciate it.
