# \[BUG\] with Dynamically Created properties and timing

**URL:** <https://forum.inductiveautomation.com/t/bug-with-dynamically-created-properties-and-timing/25467>\
**Category:** Ignition Early Access\
**Tags:** scripting\
**Created:** [May 31, 2019, 4:18pm UTC](https://forum.inductiveautomation.com/t/bug-with-dynamically-created-properties-and-timing/25467 "2019-05-31T16:18:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [May 31, 2019, 4:18pm UTC](https://forum.inductiveautomation.com/t/bug-with-dynamically-created-properties-and-timing/25467/1 "2019-05-31T16:18:41Z")

</div>

I'm currently on an Ignition 8 Nightly from a few days ago.

I was just about to submit a question about this when it struck me what the issue could be, and I've confirmed it. So a question becomes a bug report!

My setup is like such:

1. `categoryNames` is set directly with a Script Transform which creates an array of strings that are the days of the week.
2. `categoryValues` is copied directly as a Property Binding from `categoryNames`
3. `generatedColumns` is another property that is bound to a `templateColumn` property and has a script transform, but takes in `categoryValues` within the script transform to use it. It's used as follows:

```auto
xAxisValues = self.custom.alarmFrequencyHeatmap.xAxis.categoryValues
for idx, xval in enumerate(xAxisValues):
    # Do stuff with idx, xval...

```

What happens is the whole setup works perfectly within the Designer, but when I go to view it in the browser, I get the following error:

> `Traceback (most recent call last): File "<transform>", line 15, in transform TypeError: 'NoneType' object is not iterable`

However, I narrowed this down to a timing issue where it seems that all the intermediate properties are not being executed before `categoryValues` is used in the final `generatedColumns` script, so the following will fix it:

```auto
sleep(0.01)
xAxisValues = self.custom.alarmFrequencyHeatmap.xAxis.categoryValues

```

A 10ms delay fixes it. I currently have it set to 20ms, but anything less than 10ms appears to not be enough.

Just figured I'd put this in as a bug. I could just be using things wrong and it's my fault that this is happening, but I figured I'd post about it regardless.

Edit: Of course, I've realized there's a more elegant solution to just use a `while` loop to wait for the property to be generated.

```auto
while(self.custom.alarmFrequencyHeatmap.xAxis.categoryValues is None):
	pass # Wait
	
xAxisValues = self.custom.alarmFrequencyHeatmap.xAxis.categoryValues

```

Hopefully this comes in handy for anyone else who has the same issue!

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 3, 2019, 2:34pm UTC](https://forum.inductiveautomation.com/t/bug-with-dynamically-created-properties-and-timing/25467/2 "2019-06-03T14:34:56Z")

</div>

I’m not convinced this is a bug so much as everything seems to be working correctly.  
If `props.x` is `None` (or doesn’t exist), and `props.y` is bound to `props.x` and then `props.z` uses `props.y` and runs the value of `props.y` through a script, then when that evaluation is run you are attempting to iterate over a NoneType Object.

If you’re setting a property to a non-changing value in a script, then it sounds like that property should just already have that value - instead of setting it at runtime.

In an attempt to see if everything was indeed working as intended, I set up a View the following way:  
I placed a Button.  
New Custom property `Button.custom.x`, with value = “null” (None).  
New Custom property `Button.custom.categoryValues`, which is bound to `Button.custom.x`  
New Custom property `Button.custom.z`, which is bound to `Button.meta.name` and includes a Script Transform:

```auto
xAxisValues = self.custom.categoryValues
logger = system.util.getLogger('REPLICATION')
for idx, xval in enumerate(xAxisValues):
	logger.info(idx + xval)
return value

```

I actually get the same NoneType warning in the Designer, so everything seems to be working.  
 ![36%20AM](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/783d75721b5359902daa2bd5c16ee83794408386.png)

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 3, 2019, 2:37pm UTC](https://forum.inductiveautomation.com/t/bug-with-dynamically-created-properties-and-timing/25467/3 "2019-06-03T14:37:23Z")

</div>

Yeah, I realize now that this isn’t really a bug, but more of a condition that occurs due to the timing of properties being assigned, which I have to account for.

Thanks!
