# Template property change script weird errors

**URL:** <https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741>\
**Category:** Ignition\
**Created:** [July 17, 2014, 11:01am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741 "2014-07-17T11:01:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 17, 2014, 11:01am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/1 "2014-07-17T11:01:11Z")

</div>

I’m working with a template which has two UDT custom properties bound (see attached template), my problem is that I get an error related to the template´s property change script, which says:

[i]Traceback (most recent call last):

File “event:propertyChange”, line 3, in

AttributeError: ‘com.inductiveautomation.factorypmi.application.bin’ object has no attribute ‘ESTADO’

Ignition v7.6.6 (b2014040112)  
Java: Oracle Corporation 1.7.0\_51[/i]

I’m stuck since the UDT type MOTOR\_VARIADOR in fact has an attribute ESTADO (see attached image)  
[SENOBLE\_2014-07-17\_1158\_partial.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e1c8021e4cbcf421205b25744e95bc9a8db71b48.proj) (18.9 KB)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/895052544d1626ceeea52e1632c8e92ab7880597.png)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3624138461d887ccba8ca036e906c98843cbd8f4.png)

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 17, 2014, 1:32pm UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/2 "2014-07-17T13:32:17Z")

</div>

Can you show the code in the propertyChange event script?

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 17, 2014, 2:51pm UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/3 "2014-07-17T14:51:01Z")

</div>

Hi nmudge,

You can see the code in the attachment, in any case here you are:

if event.source.Compresor.FALLOS\>0:  
event.source.Color=1  
elif event.source.Variador.ESTADO:  
if event.source.Variador.MAN or not(event.source.Compresor.REMOTO):  
event.source.Color=3  
else:  
event.source.Color=4  
elif event.source.Variador.HORAS\_SERV\>event.source.Variador.HORAS\_MANTENIMIENTO:  
event.source.Color=2   
else:  
event.source.Color=0

Regards,

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 18, 2014, 9:50am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/4 "2014-07-18T09:50:55Z")

</div>

Can anybody help?

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 18, 2014, 11:11am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/5 "2014-07-18T11:11:23Z")

</div>

I’m gobsmacked, the only way I’ve been able to solve the problem, has consisted of creating new internal properties and assigning the ‘problematic’ existing attributes to these internal variables.

These are the kind of bugs that make me lose my confidence in Ignition.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [July 18, 2014, 9:30pm UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/6 "2014-07-18T21:30:18Z")

</div>

First of all you will need to separate out the events using:

`if event.propertyName == "Compresor":
  blah blah
if event.propertyName == "Variador":
 blah blah`

I don’t think you can drill down into the UDTs this way.  
You can try doing the following:  
Create Color as an internal property of the template.  
Bind it to an expression:

`if({TemplateName.Compresor::FALLOS}>0, 1,
	if({TemplateName.Variado::ESTADO}, 
 		if({TemplateName.Variado::MAN} || !{TemplateName.Compresor::REMOTO}, 3, 4),
 			if({TemplateName.Variado::HORAS_SERV}>{TemplateName.Variado::HORAS_MANTENIMIENTO}, 2, 0)))
    `

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 19, 2014, 12:13am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/7 "2014-07-19T00:13:21Z")

</div>

jpark is right. You cannot access tag values in a UDT that way. It isn’t a bug.

To access tags in a UDT instance in scripting you will need to use the system.tag.read function or bind the subtag to a property on a component.

Example:

```auto
value = system.tag.read("MOTOR1/ESTADO").value
```

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 19, 2014, 11:14am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/8 "2014-07-19T11:14:29Z")

</div>

Nick,

I don’t agree with you, I’ve many other templates for pumps, tanks, towers, etc where I’ve directly used the UDT properties in scripting and work perfectly.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 19, 2014, 3:06pm UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/9 "2014-07-19T15:06:11Z")

</div>

I tested further and you are right and I am wrong. I now agree with you that UDT instance sub tags can be referenced the way you are doing it in scripting.

Are you sure that the Variador template property is actually bound to an instance of the MOTOR\_VARIADOR UDT?

I get the same error you get when the Variador property is not bound.

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 20, 2014, 10:34am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/10 "2014-07-20T10:34:46Z")

</div>

Yes, it’s bound however I get that strange error.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 21, 2014, 4:23pm UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/11 "2014-07-21T16:23:05Z")

</div>

I see. Is it possible for you to export the window that is using the template that is having the error? Or if you don’t want to export that window then can you duplicate the same error in another window? Then upload the export to this thread.

If there is a bug and if we can reproduce it then IA will get it fixed.

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 24, 2014, 8:36am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/12 "2014-07-24T08:36:04Z")

</div>

Here you are Nick,  
[SENOBLE\_2014-07-24\_1034\_partial.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a7a2a6e7f51b0dca4ef3f71435a62d6f1b43f19c.proj) (62 KB)

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 24, 2014, 9:03pm UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/13 "2014-07-24T21:03:32Z")

</div>

Thanks Jose,

I was able to consistently reproduce the error. I would get the “AttributeError: ‘com.inductiveautomation.factorypmi.application.bin’ object has no attribute ‘ESTADO’” when opening the Aqua\_clima window. Is this when you are getting the error?

This seems to be a timing problem. I was able to fix the problem by using this code in the propertyChange event script:

```auto
def func(event=event):
	if event.source.Compresor.FALLOS>0:
		event.source.Color=1
	elif event.source.Variador.ESTADO:
		if event.source.Variador.MAN or not(event.source.Compresor.REMOTO):
			event.source.Color=3
		else:
			event.source.Color=4
	elif event.source.Variador.HORAS_SERV>event.source.Variador.HORAS_MANTENIMIENTO:
		event.source.Color=2		
	else:
		event.source.Color=0

system.util.invokeLater(func)
```

Let me know if this fixes it for you too.

---

<div class="post-metadata">

**Author:** ![jose.granero](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jose.granero/32/11190_2.png) [@jose.granero](https://forum.inductiveautomation.com/u/jose.granero)\
**Post date:** [July 27, 2014, 10:27am UTC](https://forum.inductiveautomation.com/t/template-property-change-script-weird-errors/8741/14 "2014-07-27T10:27:35Z")

</div>

Yes it does.

Thanks Nick.
