# Iterate in an Expression Tag

**URL:** <https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 19, 2022, 10:50pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193 "2022-01-19T22:50:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 19, 2022, 10:50pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/1 "2022-01-19T22:50:19Z")

</div>

I have a list of strings in one tag and basically in a separate expression tag I want to iterate through that list and see if any of the strings are equal to a specific value, If one item is set the tag to true. I don’t see any way to iterate in expression and using a script is impractical because it would need to be a global script and this does not translate well from project to project.

---

<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:** [January 19, 2022, 11:18pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/2 "2022-01-19T23:18:57Z")

</div>

What is the datatype of your list? (Show an example.)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 20, 2022, 10:15pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/3 "2022-01-20T22:15:28Z")

</div>

Without seeing your data, it’s difficult to be certain, but here’s an example that may help.

`len(lookup(split({[~]List-O-Strings}, ','), {[~]Lookup Value}, '', 0, 0))`  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37eed36286a9544f63b4969347fc0af246d535f0.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/559e5e61077766551e92ef1df98882195eaf5b49.png)

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 21, 2022, 2:59pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/4 "2022-01-21T14:59:04Z")

</div>

So I am using an expression tag to run “runScript(‘system.dataset.filterColumns(system.util.getSessionInfo(), [1])’)”, This will return a list of active users on the gateway. Now I want to have a seperate tag ‘hasAdministratorRole’ that will be true if any of the active users have the administrator role. This requires me to iterate through a list of users until I find one that has the role or I reach the end. I can’t do it all in scripting because the scripting function to check role requires authentication, which I don’t want as I would need to change my script anytime we add new users or change passwords

---

<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:** [January 21, 2022, 3:32pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/5 "2022-01-21T15:32:53Z")

</div>

> [@rrebro](#):
>
> because the scripting function to check role requires authentication

Are you sure? Running from the script console, yes, but I doubt it from gateway scope.

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [January 21, 2022, 3:36pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/6 "2022-01-21T15:36:34Z")

</div>

system.security.getUserRoles() has parameters for username and password and they are not marked as optional in the manual. Is there another way I am not seeing?

---

<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:** [January 21, 2022, 3:58pm UTC](https://forum.inductiveautomation.com/t/iterate-in-an-expression-tag/55193/7 "2022-01-21T15:58:42Z")

</div>

Hmm. You’re right. You’ll probably have to use a runScript() binding in each project’s session `auth` property to pass the information to a scripted cache.
