# If/Else on Perspective and Error Messages

**URL:** <https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [February 27, 2023, 4:47am UTC](https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344 "2023-02-27T04:47:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madeleine\_Megg](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Madeleine\_Megg](https://forum.inductiveautomation.com/u/Madeleine_Megg)\
**Post date:** [February 27, 2023, 4:47am UTC](https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344/1 "2023-02-27T04:47:26Z")

</div>

Hi,

I was wondering if I could get help with changing the state of this valve from an "open" to a "closed" state on perspective.

I am trying to make the valve toggle on a click. As such I attempted to create and if statement that handles this. While, admittedly, I know the if statement is probably constructed poorly - I am wondering why I am getting this error:

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

Note the code is as such:  
def runAction(self, event):

```
if ({self.custom.example_2} == "closed", self.props.state == "open", self.props.state == "closed")

```

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [February 27, 2023, 5:35am UTC](https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344/2 "2023-02-27T05:35:46Z")

</div>

Expression and Script(python actually) are different.

```auto
if self.custom.example_2 == "closed": # judge equal
    self.props.state = "open" # assignment
else:
    self.props.state = "close"

```

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 27, 2023, 6:12am UTC](https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344/3 "2023-02-27T06:12:17Z")

</div>

Out of curiosity, why not use a button for this?

---

<div class="post-metadata">

**Author:** ![Madeleine\_Megg](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Madeleine\_Megg](https://forum.inductiveautomation.com/u/Madeleine_Megg)\
**Post date:** [February 27, 2023, 6:22am UTC](https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344/4 "2023-02-27T06:22:11Z")

</div>

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Madeleine\_Megg](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@Madeleine\_Megg](https://forum.inductiveautomation.com/u/Madeleine_Megg)\
**Post date:** [February 27, 2023, 6:24am UTC](https://forum.inductiveautomation.com/t/if-else-on-perspective-and-error-messages/70344/5 "2023-02-27T06:24:32Z")

</div>

We need it to toggle. Since it is perspective it won't matter if we use a button or a valve. We need the valve and its current state to be shown for simplicity for our operators. Thus, a button would just add more complexity to this design.
