Error running property change script

I have a property change script running on a view custom property as follows:

if previousValue.value > 0 and currentValue.value == 0:
	system.perspective.closeDock('alarmBanner')

The intention is, when the number of alarms shown in the alarm dock goes from >0 to 0, I close the alarm dock. It works fine, but in the designer, every time I open the view, or every time the value changes, or every time I look at the change script, I get an error:

AttributeError: 'NoneType' object has no attribute 'value'

…which I would normally take to mean that either previousValue or currentValue are null - but these are arguments automatically generated by the change script, so I don’t see how they can be.

As I say - it works at runtime, I’m just wanting to understand why the designer repeatedly throws error messages at me.

previousValue is always None when the change event runs the first time (when initialChange is True).

1 Like

Ah, so the value of that custom property isn’t maintained when I close and reopen the display in the designer then. And when I edit the change script, it’s presumably reset as well. That makes sense. So this presumably I just need to preface the entire thing with if not initialChange:

It appears that initialChange is not one of the available parameters on a custom property change script, only on a tag change script. But if previousValue is not None: works just as well.