# Change Script cannot see other props?

**URL:** <https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 22, 2023, 2:47am UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458 "2023-12-22T02:47:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [December 22, 2023, 2:47am UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/1 "2023-12-22T02:47:17Z")

</div>

Hey all,

I have a change script that I would like to check the value of another property before taking action:

```auto
if currentValue:
    if custom.prop1 > 0:
          custom.prop2 = custom.prop1
    else:
          run other code

```

The error message says: `object has no attribute prop1`

Thanks

---

<div class="post-metadata">

**Author:** ![humphrey.daniel](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@humphrey.daniel](https://forum.inductiveautomation.com/u/humphrey.daniel)\
**Post date:** [December 22, 2023, 3:08am UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/2 "2023-12-22T03:08:48Z")

</div>

Can you prove custom.prop1 exists?

---

<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:** [December 22, 2023, 3:30am UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/3 "2023-12-22T03:30:12Z")

</div>

`self.custom.prop1`

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 22, 2023, 9:01am UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/4 "2023-12-22T09:01:46Z")

</div>

Where are you writing this script?  
Depending on the context, the script editor has a browse properties button to the right of the dialog. Selecting properties via the browser ensures that the properties / paths are correct.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [December 22, 2023, 7:37pm UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/5 "2023-12-22T19:37:36Z")

</div>

The script is on: `self.params.pos_1`

I was in hurry to type it up last night, I referenced the wrong property in the post.

The above should say:

```auto
if currentValue:
     if self.params.prop1 > 0:
          self.custom.prop2 = self.params.prop1
else:
     run other code

```

I used the property browser, twice to be sure there were no errors.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 22, 2023, 7:48pm UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/6 "2023-12-22T19:48:12Z")

</div>

You should be checking the value of `currentValue` which is a QualifiedValue.

Also, you should probably just combine the two conditions into one, unless there is other code that you aren't showing.

You should make sure that a previousValue exisits. The first time the change script fires, the previousValue will be None.

```auto
if all((previousValue, currentValue.value, self.params.prop1 > 0):
    self.custom.prop2 = self.params.prop1
else:
    #run other code

```

Is this error happening in the Designer or a Client?

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [December 22, 2023, 7:55pm UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/7 "2023-12-22T19:55:55Z")

</div>

Well, Rose, both Designer and Client, and here's why:

I just restarted the Designer, and guess what? That particular parameter no longer exists! I could select it in the property box, and I've been saving my work all day. To be fair to IA @cmallonee , I did have a lot of dialog boxes open while working on various bindings and scripts. However, I always hit apply, update the project and save.

I may have caused some sort of overload in the Designer - I mean four to eight windows/boxes open for various things. And another Designer window open (separate project, same gateway).

So a restart solved this problem. Perhaps there is a solution during the project update process that can propagate the changes throughout all the open windows which reference the changed objects? (Like a refresh)

Anyhow, case closed. And Merry Christmas to everyone!

Strangely enough, the changes made to the `change script` (which were made after the parameter was created), those changes were saved, but not the parameter itself!

---

<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:** [December 22, 2023, 8:05pm UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/8 "2023-12-22T20:05:35Z")

</div>

Is there any possibility that you bound the param as a two-way property, or that you made the param non-persistent?

References to non-persistent properties are prone to this issue as `currentValue` might be the initial value, and the (non-persistent) param may not have been populated yet.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [December 22, 2023, 8:51pm UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/9 "2023-12-22T20:51:32Z")

</div>

Definitely not a two-way prop. I don't recall setting it to non-persistent, though I have noticed many custom props tend to be non-persistent by default, I think that's because (not verified) they are bi-directionally bound.

I cannot confirm or deny the persistence of said param. Perhaps I'll do it again at some point.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [December 22, 2023, 11:54pm UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/10 "2023-12-22T23:54:55Z")

</div>

Ideally, the value should be None or Empty, except when a value is returned from the popup form. If `previousValue` is none, then it would not be greater than `0`, correct?

So that should prevent the code from running. But, if I do this:

```auto
if all(currentValue.value, self.params.prop1 > 0) and previousValue:
     self.custom.prop2 = self.params.prop1 
else:
   #run other code

```

what do you think?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 23, 2023, 12:35am UTC](https://forum.inductiveautomation.com/t/change-script-cannot-see-other-props/83458/11 "2023-12-23T00:35:09Z")

</div>

Moving `previousValue` out the `all()` is doing nothing but making your performance minutely worse. `all()` is true only if all values resolve to a truthy value.

So the way you wrote your condition is logically equivalent.

Also, all requires that you pass it an iterable, so the values need to be enclosed in a list, set, or tuple. Thus the extra `()` in my example.

previousValue which is a QualifiedValue object will be None on initialization of the parameter. None is a falsey condition, so the code in that branch would not execute. The next time through the previousValue will not be None, it will have a value, quality, and timestamp component.

I very deliberately put it first in the function, because `all()` is short circuiting meaning that the first falsey condition will exit the function and return false. This is important in cases where you may need to know the pervious value. It’s also good for performance.

Finally, previousValue once initialized will be the previous value of `self.params.pos_1` not `self.params.prop1` so, it being None doesn’t have any bearing on you’re script (as you have provided it). You only care in two cases (that I know of).

1. You don’t want code executing at initial change
2. You are going to attempt to access the perviousValues value component.
