Obtain current index in alarms expression configured on a array tag

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.

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

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

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

Yes, sure it's in the doc :slight_smile:

https://docs.inductiveautomation.com/display/DOC81/Tag+Data+Types

1 Like

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

Yes, some kind of "index context" in expression for Array tag is probably missing...no clue in the doc.
Perhaps @PGriffith 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.

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

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
image

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

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.:

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