# Obtain current index in alarms expression configured on a array tag

**URL:** <https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 16, 2023, 10:14am UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523 "2023-10-16T10:14:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 16, 2023, 10:14am UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/1 "2023-10-16T10:14:37Z")

</div>

I would like to change alarm label or display path for alarm configured on a **tag array**.  
I have a custom document array for the label of each element  
But in the expression, I can't figure out how to obtain the **index of the current element.**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/05ac5497ef6368433e39331dea0f503782cbbcca.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1eb89abcd41517d281c2236c0b7a4b54f56e9188.png)

---

<div class="post-metadata">

**Author:** ![zbinder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zbinder/32/28918_2.png) [@zbinder](https://forum.inductiveautomation.com/u/zbinder)\
**Post date:** [October 16, 2023, 1:02pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/2 "2023-10-16T13:02:26Z")

</div>

How is your alarm triggered? I'd think you'd need to manually configure alarms for specific bit states, in which case you'd know what the index is because you'd be manually specifying it for each index.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/554922d72ad3fe83bc4c2ca8842a01eaf7f5fd12.png)

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 16, 2023, 1:11pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/3 "2023-10-16T13:11:53Z")

</div>

The tag is an **Array of Boolean**

**The alarm condition is the same for each value in the array.**

I try to have a dedicated label or display path for each alarm with something other than "..[0]"

Label will be in a custom tag property, with an array type...and index in the tag array is index in the custom array property.

What I can't figure out is how the reference the current index in the tag expression langage

---

<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 16, 2023, 1:13pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/4 "2023-10-16T13:13:34Z")

</div>

> [@mazeyrat](#):
>
> The alarm condition is the same for each value in the array.

I wasn't aware that Alarms could handle arrays like this. Are you sure this is supported?

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 16, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/5 "2023-10-16T13:16:25Z")

</div>

Yes, sure it's in the doc 🙂

[https://docs.inductiveautomation.com/display/DOC81/Tag+Data+Types](https://docs.inductiveautomation.com/display/DOC81/Tag+Data+Types)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ced7da986842f5a3f6918e63e62278e09bba6ed7.png)

---

<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 16, 2023, 1:17pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/6 "2023-10-16T13:17:50Z")

</div>

I see. Not sure there's an allowance for expression mode there.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 16, 2023, 1:25pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/7 "2023-10-16T13:25:19Z")

</div>

> [@pturmel](#):
>
> there's an allowance for expression

Yes, some kind of "index context" in expression for Array tag is probably missing...no clue in the doc.  
Perhaps @paul-griffith is aware of this topic ?

The major usecase I see for this index is the be able to reference some other custom array prop the be able to have a sharper alarm label or display path rather the label or display path configured for the whole elements of the array tag.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [November 9, 2023, 12:43pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/8 "2023-11-09T12:43:05Z")

</div>

Perhaps @cmallonee or @ggross have some idea how to get this index in expression ?  
otherwise I'll have to fill a feature request.

---

<div class="post-metadata">

**Author:** ![N1ck](https://avatars.discourse-cdn.com/v4/letter/n/ba9def/32.png) [@N1ck](https://forum.inductiveautomation.com/u/N1ck)\
**Post date:** [November 9, 2023, 2:09pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/9 "2023-11-09T14:09:32Z")

</div>

I'm able to see the array index in the event item path: event['fullItemPath']. You would just need to parse it out. I'm grabbing this in the pipeline and emailing it:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7ea9cee4ea0a234a3bb19a465c5d8de33792c685.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/07677da96cff6087d7c64cbf0e873d266ec5789d.png)

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [November 9, 2023, 2:12pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/10 "2023-11-09T14:12:06Z")

</div>

I'm looking for a reference to the Array item index in the **expression langage**...

---

<div class="post-metadata">

**Author:** ![ggross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ggross/32/12668_2.png) [@ggross](https://forum.inductiveautomation.com/u/ggross)\
**Post date:** [November 13, 2023, 8:45pm UTC](https://forum.inductiveautomation.com/t/obtain-current-index-in-alarms-expression-configured-on-a-array-tag/80523/11 "2023-11-13T20:45:35Z")

</div>

Not sure if this is the best way to go about it, but you can do something like the following to get the index. I am sure there are potentially more polished ways to do it, but it would give you an index.:

```auto
substring(split({itemPath}, '\\[')[1,0], 0, 1)

```
