# 'in' Function in Expression Language

**URL:** <https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 8, 2024, 9:29pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998 "2024-10-08T21:29:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pico\_Sankari](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@Pico\_Sankari](https://forum.inductiveautomation.com/u/Pico_Sankari)\
**Post date:** [October 8, 2024, 9:29pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/1 "2024-10-08T21:29:13Z")

</div>

I have a string array tag that contains an array of strings. I would like to use an expression to tell if a certain value is in this array. I tried using 'a' in {[.]list tag.value}, but that gives an error configuration. Is there a way to do this in expression language or some better way to tackle this problem?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [October 8, 2024, 9:30pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/2 "2024-10-08T21:30:14Z")

</div>

`indexOf(list, item)` should work for you. Your expression would be `indexOf({yourList}, "item") != -1` for a boolean result.

> **[indexOf | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/logic/indexOf)**
>
> Searches for the first occurrence of the substring inside of string. Returns the index of where substring was found, or -1 if it wasn't found.

---

<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:** [October 8, 2024, 9:31pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/3 "2024-10-08T21:31:06Z")

</div>

`in` is a Python operator, and has no meaning in Ignition's expression language:

> **[Expression Language and Syntax | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/platform/expression-language-and-syntax#operators)**
>
> Expression Language

---

<div class="post-metadata">

**Author:** ![Pico\_Sankari](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@Pico\_Sankari](https://forum.inductiveautomation.com/u/Pico_Sankari)\
**Post date:** [October 8, 2024, 9:38pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/4 "2024-10-08T21:38:21Z")

</div>

I'm dealing with multiple values in an array so indexOf always returns -1:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/1/d1260d2ce5c18462656be468e7605bfab0893dbb.png)  
I think I'm going to use script to do this.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [October 8, 2024, 9:43pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/5 "2024-10-08T21:43:59Z")

</div>

~~What happens if you wrap the tag value in `toList()`? Like `indexOf(toList({arrayTagpath}), "item")`.~~  
If you have the Integration Toolkit module you can try wrapping the tag value in `asList()`. I believe in the background array tags are java arrays not lists, so the explicit type cast might get it into a format that `indexOf` accepts.

Edit: Whoops, combined two things into something that doesn't exist in Ignition.

---

<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:** [October 8, 2024, 10:38pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/6 "2024-10-08T22:38:51Z")

</div>

Where do get `toList()` ?

(Or do you mean the `asList()` function from my Integration Toolkit?)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [October 8, 2024, 10:44pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/7 "2024-10-08T22:44:07Z")

</div>

> [@pturmel](#):
>
> (Or do you mean the `asList()` function from my Integration Toolkit?)

I think I was thinking of this while thinking of the default type casting options from Ignition. Somehow that got turned into `toList` and I thought it came default. Whoops. 🙃

---

<div class="post-metadata">

**Author:** ![Pico\_Sankari](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@Pico\_Sankari](https://forum.inductiveautomation.com/u/Pico_Sankari)\
**Post date:** [October 8, 2024, 10:56pm UTC](https://forum.inductiveautomation.com/t/in-function-in-expression-language/96998/8 "2024-10-08T22:56:04Z")

</div>

Turns out this does work and I had a typo in the string I was checking for.  
Appreciate the help!
