# Property binding error on self.props.text

**URL:** <https://forum.inductiveautomation.com/t/property-binding-error-on-self-props-text/34574>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [May 8, 2020, 2:39pm UTC](https://forum.inductiveautomation.com/t/property-binding-error-on-self-props-text/34574 "2020-05-08T14:39:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guganathan.r](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@guganathan.r](https://forum.inductiveautomation.com/u/guganathan.r)\
**Post date:** [May 8, 2020, 2:39pm UTC](https://forum.inductiveautomation.com/t/property-binding-error-on-self-props-text/34574/1 "2020-05-08T14:39:02Z")

</div>

Hi,  
Can anyone confirm if it is a bug or expected output?

1. When I bind a self.props.text of a textfield using an expression and script transform, i’m not getting my output as self.props.text = “Exists” whereas if I use return statement it works.
2. When i did a mistake as self.props.tex = “Exists”, it created a new props property as tex and return “Exists” to it. ![ignition error](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/140ba433f96222e3af995a79cd7223d34692776f.jpeg) ![ignition error_1](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/875c5917e302cc7d67089715aec6b9239fa09968.jpeg) ![ignition error_2](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/573a9e19556c8063c38b9baf3ea3a855b69b555d.jpeg) ![ignition error_3](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/bfa66b0898bc85877a804a41b4fa6b84ec642665.jpeg)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 8, 2020, 3:12pm UTC](https://forum.inductiveautomation.com/t/property-binding-error-on-self-props-text/34574/2 "2020-05-08T15:12:58Z")

</div>

> [@guganathan.r](#):
>
> When I bind a self.props.text of a textfield using an expression and script transform, i’m not getting my output as self.props.text = “Exists” whereas if I use return statement it works.

Setting `self.props.something` in a transform is a 'side effect', and not generally using transform the way they're "meant" to be used. The recommended way to use _any_ transform, including scripting, is to mutate the incoming value and _transform_ it into something else. In a script transform, the correct way to do that is via the `return` statement; the entire script transform is modeled as a function, that accepts the value of the previous step of the binding, then returns the modified value.

Writing to other properties is _possible_, as you noticed; setting `self.props.tex` to some value is going to create a new property, because you're telling the component "here's a new value for `props.tex`". However, it shouldn't be necessary in 90% of cases, and should be avoided. Think about the maintenance problem; in six months, or a year or two, if you come back to this screen, are you going to expect the `enabled` property to be toggled by a script "hidden" in the `self.props.text` binding? Instead, you should write your transform as follows, then add a _second_ binding on a `self.props.enabled` that checks whether `self.props.text` is `EXISTS`.

```python
if value:
	ds = system.db.runNamedQuery("SELECT2CUSTOMERS")
	for row in range(ds.rowCount):
		if ds.getValueAt(row, "DETAIL_CODE") == value:
			return "EXISTS"
	else:
		return "UNIQUE CODE"
else:
	return ""

```

---

<div class="post-metadata">

**Author:** ![guganathan.r](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@guganathan.r](https://forum.inductiveautomation.com/u/guganathan.r)\
**Post date:** [May 8, 2020, 4:07pm UTC](https://forum.inductiveautomation.com/t/property-binding-error-on-self-props-text/34574/3 "2020-05-08T16:07:37Z")

</div>

Thanks! Appreciate your prompt response.

Noted on the explanation.  
Agreed that enabled should on its binding, I was scripting here on enable property just to check if my code works (since self.props.text didn’t give expected result).  
As a beginner and self learner, I wasn’t aware that ‘else’ can be used with for loop 🙂  
Thanks!
