# Change the binding of another property in perspective

**URL:** <https://forum.inductiveautomation.com/t/change-the-binding-of-another-property-in-perspective/57640>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 25, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/change-the-binding-of-another-property-in-perspective/57640 "2022-03-25T12:01:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesennis](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@jamesennis](https://forum.inductiveautomation.com/u/jamesennis)\
**Post date:** [March 25, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/change-the-binding-of-another-property-in-perspective/57640/1 "2022-03-25T12:01:22Z")

</div>

Is it possible to change the binding of a property on the change of another?

Let’s say I have:

1. 3 value properties:  
a: 1  
b: 2  
c: 3
2. A dropdown list with values: [a,b,c]
3. A label which is bound to the dropdown list with a transform:

- if the selected dropdown is a, show value of a.
- If the value is b, show value of b
- If the value is c, show value of c

Now, if select a in the dropdown, the label will show the value of a. Same with selecting b or c. All good.

However, if the dropdown is selected as a, and the value a itself changes, the label will not update, because it’s bound to the value of the dropdown list.

Ideally, what I would like is:

1. If the selected dropdown value is a, then the label is bound to property a
2. If the selected dropdown value is b, then the label is bound to property b
3. If the selected dropdown value is c, then the label is bound to property c

Is this possible?

I’ve achieved this using value changed scripts but it’s become quite messy and I’m hoping for a cleaner solution.

Any help would be hugely appreciated.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 25, 2022, 12:17pm UTC](https://forum.inductiveautomation.com/t/change-the-binding-of-another-property-in-perspective/57640/2 "2022-03-25T12:17:58Z")

</div>

I advice you put these 3 props into an object (altho it works on the base props too)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/4/3497d43fdf6edafdcbf8c528ebbe15310d8e9d79.png)  
bind your dropdown options to this object so that the label/values stay updated too  
`return [{"value":x,"label":x} for x in value]`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/c/0c2d29e7029b9563c59923a9cee6380d7ebf877b.png)  
then you can easily acces the dynamic attribues with `[]` like so  
`return self.view.custom.customValues[value]`  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2c985c891fb4bc05fc0b2c8f5c97d1217fbff4c1.png)

if you want the label to update in real time when the customValues updates and/or the dropdownvalue you will have to use a structed expression binding so you can bind those two props so it will execute when any of them changes

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e8c5040559e72cd5bde25f11901a40949d634eb5.png)

edit:  
**note** : you might want to put in some logic on the label incase the dropdown value is null to return a default message or something, else it will show a null error

```auto
if value != "":
	return self.view.custom.customValues[value]
return "Nothing is selected"

```

or in one pythony line:  
`return self.view.custom.customValues[value] if value != "" else "Select something"`

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 25, 2022, 3:13pm UTC](https://forum.inductiveautomation.com/t/change-the-binding-of-another-property-in-perspective/57640/3 "2022-03-25T15:13:54Z")

</div>

```python
return self.view.custom.customValues[value] if value != "" else "Select something"

```

Could just use `if value`, so it handles both `None` and empty strings.

---

<div class="post-metadata">

**Author:** ![jamesennis](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@jamesennis](https://forum.inductiveautomation.com/u/jamesennis)\
**Post date:** [March 25, 2022, 4:23pm UTC](https://forum.inductiveautomation.com/t/change-the-binding-of-another-property-in-perspective/57640/4 "2022-03-25T16:23:07Z")

</div>

Hey @victordcq, thank you very much for the solution! That’s worked perfectly for me. Seems like expression structure bindings were the trick I needed!

Also nice to know you can bind the drop options to an object property using python dictionary syntax, another thing I didn’t know was possible!
