# Writing tag status to tag from derived tag

**URL:** <https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 25, 2022, 6:15pm UTC](https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025 "2022-05-25T18:15:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [May 25, 2022, 6:15pm UTC](https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025/1 "2022-05-25T18:15:04Z")

</div>

I am trying to write a boolean value to a tag from a derived tag. I have may derived tag setup like this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/d/4d4b8f4f4c39e271fe873db6900b89d6a4a5155a.png)

The READ expression is this: `if(timeBetween({source}, "8:00:00 am", "8:00:30 am")|| timeBetween({source}, "8:00:00 pm", "8:00:30 pm"),true,false)`

I think I need to use a script to write(on value change) the result to the tag that needs the value, the scritp is written like this: `system.tag.writeBlocking("[~]BitWinders/BitWinder_1/LH/g_xHMI_ResetProductionData_1_.value")` The script is not executing.

Should I use a script or the WRITE of the derived tag?

---

<div class="post-metadata">

**Author:** ![matthew.ayre](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matthew.ayre/32/19499_2.png) [@matthew.ayre](https://forum.inductiveautomation.com/u/matthew.ayre)\
**Post date:** [May 26, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025/2 "2022-05-26T16:02:21Z")

</div>

Hi @mjohnson0238, why are you using a derived tag in this case? The write expression will write back to the source tag path, which is `[default]Time` in your case. The purpose of a derived tag is to differentiate between what is read from the source tag path and what is written to it.

FYI, system.tag.writeBlocking() requires a list of tags and a list of values. For example:

```auto
system.tag.writeBlocking(["myTag1", "myTag2"], [val1, val2])

```

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [May 26, 2022, 5:45pm UTC](https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025/3 "2022-05-26T17:45:34Z")

</div>

A coworker of mine suggested it, using the derived tag. On my time tag could i set up a script to execute a write to a boolean at 8am and 8pm?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 26, 2022, 6:01pm UTC](https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025/4 "2022-05-26T18:01:43Z")

</div>

You can.

```python
if not initialChange:
    if system.date.getHour24(currentValue.value) in (8,20):
        system.tag.writeBlocking(['[default]Path/To/BooleanTag'],[True])
        return
    system.tag.writeBlocking('[default]Path/To/BooleanTag'],[False])

```

---

<div class="post-metadata">

**Author:** ![matthew.ayre](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matthew.ayre/32/19499_2.png) [@matthew.ayre](https://forum.inductiveautomation.com/u/matthew.ayre)\
**Post date:** [May 26, 2022, 6:02pm UTC](https://forum.inductiveautomation.com/t/writing-tag-status-to-tag-from-derived-tag/60025/5 "2022-05-26T18:02:38Z")

</div>

You certainly can as @lrose suggested 🙂.

However, depending on what version you’re running, you can do via a scheduled gateway event script: [Gateway Event Scripts - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts)
