I might be missing something dumb, but I'm a bit perplexed... I'm trying to get a simple if statement to work in my custom alarm message.
if({eventState} = "Active", "Some Message", "Some Other Message") // this is never true
"{eventState}" // renders as Active
{eventState} // does not render
typeOf({eventState}) // shows null
I thought "Ok, maybe eventState just renders as a string but is actually an object". I tried casting it to a string. I tried using typeOf to get a hint, but typeOf returns null. I'm at a loss here for what should be a stupidly simple comparison. Please tell me I'm missing something obvious.
Maybe try just using {State}

I tried it and have the same result. I must have a fundamental misunderstanding of something.
if({state} = "Active, Unacknowledged", "Yes", "no") // always no
Have you tried adding the quotes to the property
if("{eventState}" = "Active", "Some Message", "Some Other Message")
I tried using toStr() before. Just tried with quotes as per your example and am receiving the same unsatisfying result.
Where are you creating the custom message at? In an alarm pipeline or on the tag?
It's on the tag. Do you think it has something to with the eventStatus not having a value when the if statement is evaluated?
I'm not sure {eventState}
is available in the tag's custom message expression. When I try to use it on a tag, it's shows as null. I think {eventState}
is only available in the pipeline. Using the property browser should give you a list of available props.
Yeah that's fair enough. Unfortunately I was having the same problem with {state}, which does appear to be available there.
I appreciate you taking the time to help me with this, by the way.
1 Like
Perhaps I should actually state the problem I'm trying to solve:
I want a different message to be sent off when an alarm is activated and when it is cleared. There is only one custom message field on the tag, so I'm trying to use a conditional there to make it happen. I want to accomplish this on the tag level so I don't have to create a custom alarm pipeline for each of the tags that operate like this.
Perhaps there is a better way of accomplishing this.
You should only need one pipeline for each event you want to handle, not each tag. One for Active, one for acknowledged, and one for clear. Those 3 pipelines can be set up with plenty of logic for your tags with switch, expression, script, and jump blocks. Then just set the pipeline for each event on the tags.
2 Likes
I ended up creating custom properties on my alarms to store messages for active and clear states. Then in the alarm pipeline I check whether these are set. If they are, I replace the existing message. This allows me to handle it all in one pipeline and the messages stay local to each alarm.
Thanks again for your help in exploring my problem!