# Tag change script execution

**URL:** <https://forum.inductiveautomation.com/t/tag-change-script-execution/114112>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [February 22, 2026, 2:14pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112 "2026-02-22T14:14:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 22, 2026, 2:14pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/1 "2026-02-22T14:14:57Z")

</div>

I have a memory tag with data type as dataset, it has a tag value change script associated with it  
I have one row and 13 column,  
Whenever I am making any change in any cell, the script is executing twice.  
Why it is so ?

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 22, 2026, 2:29pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/2 "2026-02-22T14:29:48Z")

</div>

Perhaps show your code…

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 22, 2026, 2:34pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/3 "2026-02-22T14:34:02Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/77027e3b7de8402093ee4479d31923e852b3db50.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/88721e6376c9fe08852a9e0b7ee97e4126604a0a.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/e/feb3cec3818c1b7750bc967401902b011e38d884.png)

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 22, 2026, 3:42pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/4 "2026-02-22T15:42:59Z")

</div>

Well I can’t see that because it’s a screenshot and your code goes beyond the visible window.

Copy and paste that and put it inside a code block.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 22, 2026, 3:44pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/5 "2026-02-22T15:44:27Z")

</div>

> [@Tag Value Change Script gets executed multiple times](https://forum.inductiveautomation.com/t/tag-value-change-script-gets-executed-multiple-times/65089):
>
> Hi All, I have a named query that inserts one row of data, I'm calling this named query from a tag value change script (which also passes the tag value to that named query). Ideally I shouldn't see any duplicate values as it's a tag value change but I'm seeing a lot of duplicates. I have seen instances when the gateway is restarted then it triggers the tag value change script somehow but even if the gateway stays on it's happening. This is an OPC tag and I don't think the PLC is writing differ…

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 23, 2026, 8:26am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/6 "2026-02-23T08:26:18Z")

</div>

Instead of a hardcoded string, can you log the value and the tag path that are passed as parameters ?

---

<div class="post-metadata">

**Author:** ![lane.duncan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lane.duncan/32/83700_2.png) [@lane.duncan](https://forum.inductiveautomation.com/u/lane.duncan)\
**Post date:** [February 23, 2026, 10:11am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/7 "2026-02-23T10:11:31Z")

</div>

I just happened to be working on appending a dataset tag today:

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	if not initialChange and currentValue.value != previousValue.value:
		logger = system.util.getLogger("TagChangeExec_Test")
		oldRowCount = previousValue.value.getRowCount()
		newRowCount = currentValue.value.getRowCount()
		logger.info(str(oldRowCount) + ", " + str(newRowCount))

```

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 23, 2026, 10:38am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/8 "2026-02-23T10:38:44Z")

</div>

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	logger = system.util.getLogger('TagChangeExec_Test')
	logger.info('Exec')
	logger.info(str(tagPath))
	logger.info(str(initialChange))
	logger.info(str(previousValue.value))
	logger.info(str(currentValue.value))

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0d4894b1a333fc69611ed777ed534d48cc6f11b3.png)

This was not the first time I configured this dataset tag, I only changed of of the existing value of the dataset.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 23, 2026, 10:40am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/9 "2026-02-23T10:40:01Z")

</div>

> [@lane.duncan](#):
>
> `if not initialChange and currentValue.value != previousValue.value:`

@svatsal77 Perhaps add this line as we’re all suggesting you do.

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 23, 2026, 10:45am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/10 "2026-02-23T10:45:30Z")

</div>

> [@lane.duncan](#):
>
> if not initialChange and currentValue.value != previousValue.value:

Updated code

```python
	logger = system.util.getLogger('TagChangeExec_Test')
	if not initialChange and currentValue.value != previousValue.value:
		logger.info('Exec')
		logger.info(str(tagPath))
		logger.info(str(initialChange))
		logger.info(str(previousValue.value))
		logger.info(str(currentValue.value))

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/480665768708ff66825ead900f7b71d5bc4f1ba2.png)

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 23, 2026, 10:46am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/11 "2026-02-23T10:46:53Z")

</div>

Add the logger _ **after** _ the “if not” code…

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 23, 2026, 10:51am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/12 "2026-02-23T10:51:57Z")

</div>

Done, added the logger initialization under the if condition, but same behavior, triggering twice.

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	
	if not initialChange and currentValue.value != previousValue.value:
		logger = system.util.getLogger('TagChangeExec_Test')
		logger.info('Exec')
		logger.info(str(tagPath))
		logger.info(str(initialChange))
		logger.info(str(previousValue.value))
		logger.info(str(currentValue.value))

```

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

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 23, 2026, 10:53am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/13 "2026-02-23T10:53:58Z")

</div>

JSON tag :

```python
{
  "valueSource": "memory",
  "eventScripts": [
    {
      "eventid": "valueChanged",
      "script": "\t\n\tif not initialChange and currentValue.value !\u003d previousValue.value:\n\t\tlogger \u003d system.util.getLogger(\u0027TagChangeExec_Test\u0027)\n\t\tlogger.info(\u0027Exec\u0027)\n\t\tlogger.info(str(tagPath))\n\t\tlogger.info(str(initialChange))\n\t\tlogger.info(str(previousValue.value))\n\t\tlogger.info(str(currentValue.value))"
    }
  ],
  "dataType": "DataSet",
  "name": "Tag0",
  "value": "{\"columns\":[{\"name\":\"Col0\",\"type\":\"java.lang.Boolean\"},{\"name\":\"Col1\",\"type\":\"java.lang.String\"}],\"rows\":[[true,\"0\"]]}",
  "tagType": "AtomicTag"
}

```

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 23, 2026, 11:01am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/14 "2026-02-23T11:01:36Z")

</div>

> [@svatsal77](#):
>
> ```python
> logger.info(str(previousValue.value))
> logger.info(str(currentValue.value))
> 
> ```

You literally are telling your logger to log twice. Because you aren’t pulling the raw values out of the datasets, you can’t see the inner guts that one line is the previous value’s dataset data and the other is the current values.

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 23, 2026, 11:11am UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/15 "2026-02-23T11:11:50Z")

</div>

Pardon, I didn't get that, as per my understanding the script should execute only once, and it is not the initial time the tag is configured or changed. I'm just logging the value of previous and current data, if you see the images, there are two sets of data getting logged

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/c/0cb232dcfa492c18f3552aabe159296b26763d67.png)

Removed the

```python
logger.info(str(previousValue.value))
logger.info(str(currentValue.value))

```

Only kept :

```python
logger.info(str(currentValue.value))

```

---

<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:** [February 23, 2026, 2:03pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/16 "2026-02-23T14:03:55Z")

</div>

Please show the code that runs the named query (the source of the tag changes) and add logging to **that** code--it may be running twice also.

---

<div class="post-metadata">

**Author:** ![svatsal77](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@svatsal77](https://forum.inductiveautomation.com/u/svatsal77)\
**Post date:** [February 23, 2026, 4:53pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/17 "2026-02-23T16:53:44Z")

</div>

There's no named query, i am just observing the tag change script behavior with dataset as data type

---

<div class="post-metadata">

**Author:** ![Nol](https://avatars.discourse-cdn.com/v4/letter/n/8e8cbc/32.png) [@Nol](https://forum.inductiveautomation.com/u/Nol)\
**Post date:** [February 23, 2026, 5:17pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/18 "2026-02-23T17:17:53Z")

</div>

Have you configured anything in the gateway events for a tag change as well on the tag itself? That could cause it to execute twice if you also put loggers in there.

I setup exactly what you've shown, memory dataset tag, 1x2 dataset, bool + int, with the same tag change script and it only executes once in 8.3.2. I also tested each way of changing the tag in the editor, in the browser, change one vs both columns, etc. Only executes once for me.

Though mine says PyDataset instead?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/c/dc2798eb19043b27d7e73c7c330422d125d18fbc.png)

---

<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:** [February 23, 2026, 5:25pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/19 "2026-02-23T17:25:19Z")

</div>

> [@svatsal77](#):
>
> There's no named query

Then show the code that is changing your dataset.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 23, 2026, 6:06pm UTC](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112/20 "2026-02-23T18:06:11Z")

</div>

> [@Nol](#):
>
> Though mine says PyDataset instead?

Pretty sure that’s a backend change by IA between 8.1 and 8.3

[Next page](https://forum.inductiveautomation.com/t/tag-change-script-execution/114112.md?page=2)
