# UDT Instance tag change not working

**URL:** <https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282>\
**Category:** Ignition\
**Created:** [April 18, 2025, 1:31pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282 "2025-04-18T13:31:46Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [April 18, 2025, 6:50pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/21 "2025-04-18T18:50:12Z")

</div>

I figured out the commented-out lines still caused failures.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [April 18, 2025, 7:00pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/22 "2025-04-18T19:00:59Z")

</div>

> [@pturmel](#):
>
> I suggest you abandon `.format()` entirely

I'm interested in understanding your reasoning for this, beyond just preference and this particular Ignition bug. I really just adopted using .format() generally because at the time I was self educating on Python it was presented as the modern way of doing it and I've grown accustomed to it. I also like that it automatically handles string conversion for various objects types and feels better than string concatenation with `+`... But I'm feeling I can be swayed with some solid rationale.

How is .`infof()` ...

> [@pturmel](#):
>
> ...much more efficient, and CPU friendly when a logging level is disabled.

---

<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:** [April 18, 2025, 7:05pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/23 "2025-04-18T19:05:40Z")

</div>

The printf-style logger methods entirely skip the string formatting operation if the log level is disabled. When enabled, the formatting operation is pure java, not jython.

If you are careful to avoid preprocessing arguments for the loggers, the disabled level case factors out to close to nothing, CPU-wise. You should try to make sure your jython class objects, if you are using any, have proper ` __str__ ()` implementations, so you can pass the object directly to loggers. The call to ` __str__ ()` will be skipped where possible.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [April 18, 2025, 8:47pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/24 "2025-04-18T20:47:05Z")

</div>

> [@Thomas\_Salisbury](#):
>
> The second example is still causing silent failures for us

@Thomas_Salisbury , I confirmed that the first example below will silently fail but the second will generate the log messages.

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	logger = system.util.getLogger(tag.name)
	logger.info("valueChanged: tagPath={0}, previousValue={1}, currentValue={2}, initialChange={3}, missedEvents={4}".format(
		tagPath, previousValue, currentValue, initialChange, missedEvents
	))

```

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	logger = system.util.getLogger(tag.name)
	logger.info("valueChanged: tagPath={}, previousValue={}, currentValue={}, initialChange={}, missedEvents={}".format(
		tagPath, previousValue, currentValue, initialChange, missedEvents
	))

```

And this one works also, per @pturmel's recommendation.

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	logger = system.util.getLogger(tag.name)
	logger.infof("valueChanged: tagPath=%s, previousValue=%s, currentValue=%s, initialChange=%s, missedEvents=%s",
		tagPath, previousValue, currentValue, initialChange, missedEvents
	)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 18, 2025, 9:04pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/25 "2025-04-18T21:04:29Z")

</div>

> [@tyler.bennett](#):
>
> I really just adopted using .format() generally

Note Phil's caveat here:

> [@pturmel](#):
>
> entirely everywhere loggers are involved.

.format is generally more useful/readable and you're more than welcome to use whatever (Python 2) formatting strategy you want for general purpose assembly of strings. Phil's advice is **specifically** when dealing with logging.

As a further aside, since I'm surprised Phil hasn't brought it up yet: Note that you can also immediately transfer from a tag script to a project library script (in the gateway scripting project) and write the script however you like, without this issue with format strings. It's only curly braces within the literal code string(s) _directly attached to the tag_ that cause the issue.

---

<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:** [April 18, 2025, 9:27pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/26 "2025-04-18T21:27:08Z")

</div>

> [@paul-griffith](#):
>
> since I'm surprised Phil hasn't brought it up yet

Only so much bandwidth today for swatting code smells. 😐

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [April 18, 2025, 10:00pm UTC](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282/27 "2025-04-18T22:00:39Z")

</div>

funny thing. I literally did that. moved the script to the project library and just called it form the tag change

[Previous page](https://forum.inductiveautomation.com/t/udt-instance-tag-change-not-working/105282.md?page=1)
