# Global name 'status\_red' is not defined

**URL:** <https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999>\
**Category:** Ignition\
**Tags:** scripting, ignition80\
**Created:** [November 26, 2020, 9:18pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999 "2020-11-26T21:18:32Z")\
**Posts on this page:** 16\
**Page:** 2

<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:** [November 27, 2020, 11:04pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/21 "2020-11-27T23:04:00Z")

</div>

And you can edit comments to fix formatting instead of reposting the same thing… ):

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 27, 2020, 11:06pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/22 "2020-11-27T23:06:04Z")

</div>

ah, sorry everyone.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 27, 2020, 11:09pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/23 "2020-11-27T23:09:08Z")

</div>

I think you need to change the bottom part (starting line 64) to:

```auto
	data = [{"value": unit, "style": {"classes": color}}
				,{"value": company, "style": {"classes": color}}
				,{"value": location, "style": {"classes": color}}
				,{"value": volts, "style": {"classes": color}}]
	ds.append(data)

```

Previously you were setting the `style` key to a value, whereas the value of the `style` key should be a dictionary/object with keys within it.

You also have a large number of singular tag reads in the script which will significantly impact performance, especially if you have a reasonable number of units. You should consider changing this to read tags all at once and then process the values. As a point of reference, I changed a colleague’s script from reading 5 tags at once, many times over in a loop, to reading all tags at once and it reduced the script runtime to something like 2% of the time.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 27, 2020, 11:15pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/24 "2020-11-27T23:15:32Z")

</div>

You’re a genius, it worked, and it took only seconds, on vision it would take like 2 minutes. Thanks all for the help, especially you.jake

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 27, 2020, 11:16pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/25 "2020-11-27T23:16:25Z")

</div>

> [@codersmurf](#):
>
> and it took only seconds

It could be much faster than seconds, you could get this down to ms 🙂

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 27, 2020, 11:17pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/26 "2020-11-27T23:17:41Z")

</div>

Trust me, with vision being so slow this is ridiculously fast. I actually had code to change the button so people knew they had hit it and it would change back after words.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 27, 2020, 11:20pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/27 "2020-11-27T23:20:38Z")

</div>

One last thing, I have the columns setup in the table, but they are showing up as column\_1 - column\_4. Do I need to do something special?Thx, jake

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 27, 2020, 11:24pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/28 "2020-11-27T23:24:15Z")

</div>

Try this (completely untested, and I haven’t replaced the reads in the getColor function either):

```auto
def Load(caller):
	units_tag = caller.session.props.auth.user.userName
	hide_customer = False;
	if units_tag == 'TOPSDemo':
		hide_customer = True
	
	units = system.tag.readBlocking(['[default]' + units_tag + '/Units'])[0].value.split(',')
	
	unitList = caller.getSibling("Units")
	#ds = system.dataset.clearDataset(unitList.props.data)
	ds = []

    units_enabled = [tag.value for tag in system.tag.readBlocking(['[default]' + unit + '.enabled' for unit in units]))
    units_comploc = [tag.value for tag in system.tag.readBlocking(['[default]Disabled-' + unit for unit in units]))
    units_company = [tag.value for tag in system.tag.readBlocking(['[default]' + unit + '/Company' for unit in units]))
    units_location = [tag.value for tag in system.tag.readBlocking(['[default]' + unit + '/Location' for unit in units]))
    units_compv = [tag.value for tag in system.tag.readBlocking(['[default]' + unit + '/CompMainsVoltage' for unit in units]))

	for idx, unit in enumerate(units):
		#system.gui.messageBox(unit)
		color = GetColor(unit)
		company = ""
		location = ""
		volts = ""
		d = units_enabled[idx] #system.tag.readBlocking(['[default]' + unit + '.enabled'])[0].value
		if d == False:
			comploc = units_comploc[idx] #system.tag.readBlocking(['[default]Disabled-' + unit])[0].value.split(',')
			company = comploc[0]
			location = comploc[1]
			volts = "NA"
		else:
			if hide_customer == True:
				company = 'NA'
				location = 'NA'
			else:
				company = units_company[idx] #system.tag.readBlocking(['[default]' + unit + '/Company'])[0].value
				location = units_location[idx] #system.tag.readBlocking(['[default]' + unit + '/Location'])[0].value
			compv = units_compv[idx] #system.tag.readBlocking(['[default]' + unit + '/CompMainsVoltage'])[0]
			if compv and compv.quality.isGood() == True:
				volts = "%4.1f" % compv.value
			else:
				volts = "NA"
		data = [{"value": unit, "style": {"classes": color}}
				,{"value": company, "style": {"classes": color}}
				,{"value": location, "style": {"classes": color}}
				,{"value": volts, "style": {"classes": color}}]
		ds.append(data)

	unitList.props.data = ds

```

You could go further and combine this into a single read, but this will give a huge improvement as it is

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 27, 2020, 11:29pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/30 "2020-11-27T23:29:47Z")

</div>

cool, I try that out when optimizations come into play.Thx, any thoughts on the headers not showing up from the controls props?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 27, 2020, 11:36pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/31 "2020-11-27T23:36:39Z")

</div>

> [@nminchin](#):
>
> data = [{"value": unit, "style": {"classes": color}} ,{"value": company, "style": {"classes": color}} ,{"value": location, "style": {"classes": color}} ,{"value": volts, "style": {"classes": color}}] ds.append(data)

Whoops, replace this with:

```auto
	data = {"Unit": {"value": unit, "style": {"classes": color}}}
			,{"Company": {"value": company, "style": {"classes": color}}}
			,{"Location": {"value": location, "style": {"classes": color}}}
			,{"Volts": {"value": volts, "style": {"classes": color}}}
	ds.append(data)

```

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 27, 2020, 11:44pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/32 "2020-11-27T23:44:11Z")

</div>

![ignition3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cd7bebcdf444ab9826e2b4262b8b29b9c5ddcf3f.jpeg)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 27, 2020, 11:52pm UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/33 "2020-11-27T23:52:44Z")

</div>

I edited the other post, removed the outer list brackets []

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 28, 2020, 12:00am UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/34 "2020-11-28T00:00:07Z")

</div>

It doesn’t like it then, the commas confuse it seems like

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 28, 2020, 12:10am UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/35 "2020-11-28T00:10:00Z")

</div>

Silly, I should have replaced the square brackets with curly. Try again, edited post.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 28, 2020, 12:17am UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/36 "2020-11-28T00:17:43Z")

</div>

That made the list not do anything again. I tried this and it still didn’t work:

```
unitList.props.data = ds
unitList.props.columns[0].field = "Unit"
unitList.props.columns[0].field = "Company"
unitList.props.columns[0].field = "Location"
unitList.props.columns[0].field = "CompVolts"

```

It’s really strange.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [November 28, 2020, 2:39am UTC](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999/37 "2020-11-28T02:39:08Z")

</div>

Got it, thx for the help, this worked, not sure why not before:

```auto
		data = {"Unit": {"style": {"classes": color}, "value": unit}
				,"Company": {"style": {"classes": color}, "value": company}
				,"Location": {"style": {"classes": color}, "value": location}
				,"CompVolts": {"style": {"classes": color}, "value": volts}}

```

[Previous page](https://forum.inductiveautomation.com/t/global-name-status-red-is-not-defined/40999.md?page=1)
