# Ignition tag change script help

**URL:** <https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 21, 2026, 9:59pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462 "2026-01-21T21:59:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [January 21, 2026, 9:59pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/1 "2026-01-21T21:59:50Z")

</div>

Hello, I have made an interface with several tables that are fed by a named query. Anytime the OPC tag changes values, a message is sent to reload the table. I know the message handler is correct.

On the view for the table, I placed a custom property with a tag change script. When the tag changes, it is supposed to automatically refresh the table. the problem is it is always one behind. I loads the last data point, not the one it just switched to. This may be due to my transaction group falling sending after my tag change script runs. here is the script.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/f/7f4916e2d4ef44427792264fd3251780dbc07e2a.png)

If you look at the image the end has already been sent, but has not loaded.

“

def valueChanged(self, previousValue, currentValue, origin, missedEvents):  
if currentValue is not None:  
system.perspective.sendMessage(  
messageType="refresh",  
scope="view"  
)

“

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [January 21, 2026, 10:35pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/2 "2026-01-21T22:35:11Z")

</div>

Looks like you might have messed up the preformatted text formatting, see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

> [@Nathaniel\_Webb](#):
>
> This may be due to my transaction group falling sending after my tag change script runs

You need to guarantee that the transaction group runs and completes before you trigger the table refresh. You are ending up with a race condition between your transaction group and your query against the DB for the latest records.

The only way to guarantee ordering is to script your transaction in a [Gateway Tag Change event](https://www.docs.inductiveautomation.com/docs/8.1/platform/scripting/scripting-in-ignition/gateway-event-scripts#tag-change-scripts), and at the end of the transaction script, use `system.util.sendMessage` to send a message aimed at the project where this view resides.

From there, in the [Session Message Handler](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-session-events-scripts#message), use `system.perspective.sendMessage` with a session scope to trigger the table refresh. Adjust your table message handler to listen at the session level.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 21, 2026, 10:57pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/3 "2026-01-21T22:57:02Z")

</div>

> [@Nathaniel\_Webb](#):
>
> if currentValue is not None:

Also I don’t think `currentValue` is _ever_ `None`. `previousValue` in the other hand _can_ be. Perhaps you are meaning to check the `value` of it instead? Eg `currentValue.value`

(Not that this would cause the issue you're seeing)

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [January 22, 2026, 4:29pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/4 "2026-01-22T16:29:44Z")

</div>

I have gone this route now:

```python
if previousValue.value != currentValue.value:
base = "[Sample_Tags]Devices/R101_Tab_Inserter/"

paths = [
    base + "Button_Input_Alias",
    base + "Date",
    base + "Head Number",
    base + "Interface Box Serial",
    base + "Position",
    base + "Time"
]

values = system.tag.readBlocking(paths)

# Write directly to DB with inline params dictionary
system.db.runNamedQuery(
    "Tag_Inserter/Tab_Inserter_MIS_Raw",
    {
        "Button_Input_Alias": values[0].value,
        "Date": values[1].value,
        "Head_Number": values[2].value,
        "Interface_Box_Serial": values[3].value,
        "Position": values[4].value,
        "Time": values[5].value
    }
)

# Notify Perspective sessions
system.util.sendMessage(
    project="ORBC_DAQ",
    messageType="refreshR101Table",
    payload={},
    scope="session"
)

```

The named query runs immediately. technically the named query must complete a write to the database. For some reason it is still not refreshing the table. I have the scope set to session, scope, and view for the message handler located on the table that needs to be refreshesh. the script is

```python
def onMessageReceived(self, payload):
    self.refreshBinding("props.data")

```

What could I be doing, I have polling turn off. Its certainly not receiving data. The timing is fine, becaause I can have several rows that haven’t been reloaded and it will still do nothing.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [January 22, 2026, 4:41pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/5 "2026-01-22T16:41:01Z")

</div>

If you are using `system.util.sendMessage` you must have a [Session Message Handler](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-session-events-scripts#message) on the project with the table to re-transmit the message for component message handlers in the local perspective session. It can be as simple as:

```python
def handleMessage(session, payload):
    system.perspective.sendMessage("MessageName", payload, scope="session")

```

Pay attention to the differences between `system.util.sendMessage` and `system.perspective.sendMessage`. Component and view message handlers are unable to consume messages sent from `system.util.sendMessage`, hence why you need the Session Message Handler to re-transmit the message.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [January 22, 2026, 6:06pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/6 "2026-01-22T18:06:36Z")

</div>

I did this and it worked.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [January 22, 2026, 8:21pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/7 "2026-01-22T20:21:14Z")

</div>

At least I thought it did. Could this be due to scope? here is my tag change script:

```python
if previousValue.value != currentValue.value:
    base = "[Sample_Tags]Devices/R101_Tab_Inserter/"

    paths = [
        base + "Button_Input_Alias",
        base + "Date",
        base + "Head Number",
        base + "Interface Box Serial",
        base + "Position",
        base + "Time"
    ]

    values = system.tag.readBlocking(paths)

    # Write directly to DB with inline params dictionary
    system.db.runNamedQuery(
        "Tag_Inserter/Tab_Inserter_MIS_Raw",
        {
            "Button_Input_Alias": values[0].value,
            "Date": values[1].value,
            "Head_Number": values[2].value,
            "Interface_Box_Serial": values[3].value,
            "Position": values[4].value,
            "Time": values[5].value
        }
    )

    # Notify Perspective sessions
    system.util.sendMessage(
        project="ORBC_DAQ",
        messageHandler="refreshR101message",
        scope="S"
    )

```

Here is my gateway message handler:

```python
def handleMessage(payload):

    system.perspective.sendMessage("refreshR101Table", scope="session")

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 22, 2026, 8:54pm UTC](https://forum.inductiveautomation.com/t/ignition-tag-change-script-help/113462/8 "2026-01-22T20:54:35Z")

</div>

> [@Nathaniel\_Webb](#):
>
> `if previousValue.value != currentValue.value:`

This not safe. On tag restart `previousValue` will be `None` and your script will fail. You must always check the `initialChange` flag **before** accessing `previousValue`.
