# Expression for Value in Array

**URL:** <https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [August 2, 2021, 6:59pm UTC](https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467 "2021-08-02T18:59:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [August 2, 2021, 6:59pm UTC](https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467/1 "2021-08-02T18:59:49Z")

</div>

Hi,

After the dropdown bi-directional binding to array tags have been fixed, I want to test if something is in the selected array.

As a test I have a dropdown where days of the week are selected. I want to make an expression tag to check if today (`getDayOfWeek(now())`) is in that array, but I can’t seem to find the equivalent of the Python `in`. See example below:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/39bbacbf13856ba7deb32b7cf55a8245d32c0271.png)

Is there an expression I can use? I don’t really want to resort to `runScript()`

Thanks,  
Deon

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 2, 2021, 7:52pm UTC](https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467/2 "2021-08-02T19:52:12Z")

</div>

Can you create a change script on `value` (on the dropdown) then push this where you want?

---

<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:** [August 2, 2021, 8:38pm UTC](https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467/3 "2021-08-02T20:38:32Z")

</div>

> [@deon.korb](#):
>
> I want to make an expression tag to check if today ( `getDayOfWeek(now())` ) is in that array,

Starting in 8.1.8 (releasing very soon), you'll be able to use `indexOf()` on the array for this; it'll return `-1` if the target value is not found.  
Unfortunately, in the meantime I think `runScript` is your best bet.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [August 3, 2021, 6:28am UTC](https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467/4 "2021-08-03T06:28:24Z")

</div>

Excellent. I can wait for 8.1.8.

I saw the `indexOf()`, but for the time being the documentation only refers to string. Will use when upgrading.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [June 2, 2023, 8:46pm UTC](https://forum.inductiveautomation.com/t/expression-for-value-in-array/49467/5 "2023-06-02T20:46:46Z")

</div>

In case this helps others...

The current description in the [v8.1 user manual entry for indexOf()](https://docs.inductiveautomation.com/display/DOC81/indexOf) makes no mention of compatibility with lists.

> **Description**
> 
> 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. The first position in the string is position 0.

However, in the **Syntax** section there is a note for version 8.1.8, stating compatibility with "tuples and lists". It is easy to overlook if you are just scanning descriptions... as I was.

> This feature was changed in Ignition version **8.1.8** :
> 
> The object parameter now accepts tuples and lists.
