# Set a Tag via an Expression

**URL:** <https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217>\
**Category:** Ignition\
**Created:** [April 17, 2019, 6:49pm UTC](https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217 "2019-04-17T18:49:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil\_B](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@Neil\_B](https://forum.inductiveautomation.com/u/Neil_B)\
**Post date:** [April 17, 2019, 6:49pm UTC](https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217/1 "2019-04-17T18:49:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [April 17, 2019, 7:19pm UTC](https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217/2 "2019-04-17T19:19:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Neil\_B](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@Neil\_B](https://forum.inductiveautomation.com/u/Neil_B)\
**Post date:** [April 17, 2019, 7:47pm UTC](https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217/3 "2019-04-17T19:47:24Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [April 17, 2019, 7:59pm UTC](https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217/4 "2019-04-17T19:59:00Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![Neil\_B](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@Neil\_B](https://forum.inductiveautomation.com/u/Neil_B)\
**Post date:** [April 17, 2019, 8:06pm UTC](https://forum.inductiveautomation.com/t/set-a-tag-via-an-expression/24217/5 "2019-04-17T20:06:05Z")

</div>

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.
