Set a Tag via an Expression

Ok, I think I’m failing at searching…

How do you set a tag value via an expression?
I’m trying to set a boolean to true

tag("[~]Trigger") = true

The only way you could set a tag value from the expression language would be using runScript but is probably unorthodox to do so. The better way would be to use tag events. I can’t give a better recommendation without knowing what exactly what you are trying to do.

I’m actually making a transaction group that I wanted to use both the on change value with a specific group trigger. So this was my attempt at a work around…

I still don’t fully understand what you are trying to do. If you want to create a tag that will trigger the transaction group you will want to create a new expression item in the Run-Always Expression Items area. In the expression item you would use an if-statement to determine if it’s value is 0 or 1. Then use this as the group trigger. For example, if you wanted the transaction group to run at a certain time, then you could use the expression below that is true when it is 2:30am on Monday, and false at any other time.

if(dateFormat(now(0), "E") = "Mon" && dateFormat(now(0), "HH:mm") = "02:30", 1, 0)

I was having an issue getting a triggered expression item to execute when I had both “Only evaluate when values have changed” on a custom tag selection AND “Execute this group on a trigger”

They both worked individually, but when both enabled neither executed.
I know I’m missing something simple…

My original question was answered, you can’t set a tag via the expression language.

1 Like