# Perspective - Binding issue on loading

**URL:** <https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [August 6, 2021, 2:27pm UTC](https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645 "2021-08-06T14:27:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 6, 2021, 2:27pm UTC](https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645/1 "2021-08-06T14:27:34Z")

</div>

8.1.8

I get error on binding while loading page, it appears when I use an object in expression and try to access a key throw a script. Error appear shortly but it’s agressent.

 ![2021-08-06_10h11_29](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/392bfca40b96f8a865a641241f4eca3e28189b13.png)

![2021-08-06_10h27_00](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d8aacaeac9af45cffcf789c2f15e448dbb78344a.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1ae73a68442b31540721157544b664e4203f8335.png)

![2021-08-06_10h31_21](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/d/4dd349372c5b615b53689ba7f347c9562b9f0474.gif)

---

<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:** [August 6, 2021, 2:39pm UTC](https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645/2 "2021-08-06T14:39:25Z")

</div>

It’s hard to tell without seeing all of the pieces, but while a KeyError is definitely encountered when looking for a key “enabled”, it appears to be the “enabled” key of a “myTrigger” object, not the `typeAction` object you supplied a screenshot for. Could you provide insight into the `myTrigger` object?

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 6, 2021, 2:44pm UTC](https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645/3 "2021-08-06T14:44:54Z")

</div>

I have 3 types of trigger, myTrigger is the active one and comes from type\_action in that case

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/4/c4a1c41420fd8ff44e11f5264e57ce65a6b6ae33.png)

```auto
def transform(self, value, quality, timestamp):
	"""
	Transform the incoming value and return a result.

	Arguments:
		self: A reference to the component this binding is configured on.
		value: The incoming value from the binding or the previous transform.
		quality: The quality code of the incoming value.
		timestamp: The timestamp of the incoming value as a java.util.Date
	"""
	classes="Table/tbl-txt-center-bold Text/txt-lbl-overflow-hidden Colors/borderColor-black Text/txt-desc"
	
	try:
		if not "Alerts" in value["color_name"]:
			if not self.view.params.alert_value_path is None and not self.view.params.alert_value_path=="":
				my_codes = _Functions.getConstDict(self.view.custom.severity_path)
				my_codes = _Functions.reverseDict(my_codes)
				alert_code = my_codes[str(value["alert"])]
			else:
				alert_code = ""
	except:
		return	
#MODE
	if value["type"]=="mode":
		if not value["text_classes"] is None:
			classes += value["text_classes"]
		
		if not alert_code=="" and value["myTrigger"]["active"] and value["alert"] > 0:
			return classes + " Alerts/backgroundColor-" + alert_code + " Objects/toggle-pointer-enabled"
		elif value["myTrigger"]["pending"]:
			return classes + " Colors/backgroundColor-" + value["color_name"] + "Light-" + value["color_name"] + "Dark_blink Colors/color-white Objects/toggle-pointer-enabled"
		elif value["myTrigger"]["active"]:
			return classes + " Colors/backgroundColor-" + value["color_name"] + "Light Colors/color-white Objects/toggle-pointer-enabled" #Colors/backgroundColor-green
		elif value["myTrigger"]["can_request"]:
			return classes + " Colors/backgroundColor-" + value["color_name"] + "Dark Colors/color-white Objects/toggle-pointer-enabled"
		else:
			if not value["has_needs"]:
				return classes + " Colors/backgroundColor-grayLight Colors/color-gray Objects/toggle-pointer-disabled"
		return classes + " Colors/backgroundColor-grayLight Colors/color-gray Objects/toggle-pointer-enabled"
#ACTION
	elif value["type"]=="action":
		if (not value["myTrigger"]["enabled"] or value["myTrigger"]["enabled"] is None) and not value["myTrigger"]["started"] and not value["myTrigger"]["custom_view_exist"]:
			return classes + " Colors/backgroundColor-grayLight Colors/color-gray Objects/toggle-pointer-enabled"#Colors/txt-disabled-color"# Objects/toggle-pointer-disabled"
		
		if not value["text_classes"] is None and not value["text_classes"]=="":
			std_color = value["text_classes"]
		else:
			std_color = "Colors/color-white"
		
		if value["myTrigger"]["custom_view_exist"] and not value["myTrigger"]["can_start"]:
			return classes + " Colors/backgroundColor-grayLight Colors/color-gray Objects/toggle-pointer-enabled"
		elif value["myTrigger"]["risky"] and value["myTrigger"]["enabled"] and not value["myTrigger"]["started"]:
			return classes + " Colors/backgroundColor-amber " + std_color + " Objects/toggle-pointer-enabled"
		elif value["myTrigger"]["started"] and not value["myTrigger"]["ended"]: #value["enabled"] and 
			return classes + " Colors/backgroundColor-" + value["color_name"] + "-" + value["color_name"] + "Light_blink " + std_color + " Objects/toggle-pointer-disabled"
		elif value["myTrigger"]["enabled"] and value["myTrigger"]["signal"]:
			return classes + " Colors/backgroundColor-" + value["color_name"] + "Light " + std_color + " Objects/toggle-pointer-disabled"
		return std_color + " " + classes + " Colors/backgroundColor-" + value["color_name"] + " Objects/toggle-pointer-enabled"
#TRIGGER
	elif value["type"]=="trigger":
		if not value["text_classes"] is None and not value["text_classes"]=="":
			std_color = value["text_classes"]
		else:
			std_color = "Colors/color-white"
		
		if "Alerts" in value["color_name"]:
			if value["myTrigger"]["enabled"] and not value["myTrigger"]["signal"]:
				return classes + " " + value["color_name"] + " " + " Objects/toggle-pointer-enabled"
			elif value["myTrigger"]["enabled"] and value["myTrigger"]["signal"]:
				return classes + " " + value["color_name"] + "_blink Objects/toggle-pointer-disabled "
			return classes + " " + value["color_name"] + " " + " Objects/toggle-pointer-disabled"
		else:	
			if value["myTrigger"]["enabled"] and not value["myTrigger"]["signal"]:
				return classes + " Colors/backgroundColor-" + value["color_name"] + " " + std_color + " Objects/toggle-pointer-enabled"
			elif value["myTrigger"]["enabled"] and value["myTrigger"]["signal"]:
				return classes + " Colors/backgroundColor-" + value["color_name"] + "-" + value["color_name"] + "Light_blink Objects/toggle-pointer-disabled " + std_color
			return classes + " Colors/backgroundColor-grayLight Colors/color-gray Objects/toggle-pointer-disabled"
	return value["type"]

```

---

<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:** [August 6, 2021, 2:58pm UTC](https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645/4 "2021-08-06T14:58:33Z")

</div>

What you’re encountering is that the binding has not resolved by the time you try to access the `enabled` key. You could either opt-out of the overlay in the binding dialog, or you could gracefully handle the KeyError within the script you provided:

```auto
try:
    ...
    elif value["type"] == "action":
        if (not value["myTrigger"]["enabled"] or ...
except KeyError:
    # do something else here

```

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 9, 2021, 12:23pm UTC](https://forum.inductiveautomation.com/t/perspective-binding-issue-on-loading/49645/5 "2021-08-09T12:23:52Z")

</div>

Why that issue is newer in 8.1.8 ? I nerver encounter that before, and many of our pages has that issue now.
