# Trouble with 'if' statement, button event

**URL:** <https://forum.inductiveautomation.com/t/trouble-with-if-statement-button-event/76892>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 25, 2023, 5:49pm UTC](https://forum.inductiveautomation.com/t/trouble-with-if-statement-button-event/76892 "2023-07-25T17:49:50Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [July 25, 2023, 7:32pm UTC](https://forum.inductiveautomation.com/t/trouble-with-if-statement-button-event/76892/5 "2023-07-25T19:32:10Z")

</div>

I don't know what's going on with the parameter problem but I offer the following to reduce your code and the brittleness of your project.

1. On the view create a custom property object with structure something like this:

```auto
dataLeft
    desc :
    notes :
    classification :
    category :
    stocked :
    review :
    shortDesc :

```

1. Bind each of the respective `coord_Left` components to the custom object and make the bindings bi-directional.
2. Now the first block of seven lines of your code becomes,

```auto
dataLeft = self.view.custom.dataLeft

```

1. Create a second custom property object, `dataRight`.
2. Generate the `coord_Right` components using:

```auto
dataRight = {}
dataRight["Item ID"] = item_id
dataRight["Category"] = str(dataLeft["category"])
dataRight["Class"] = str(dataLeft["classification"])
dataRight["Desc"] = desc[quote="mdemaris, post:3, topic:76892"] # What's going on here?
dataRight["Short"] = dataLeft["shortDesc"]
dataRight["Stocked"] = str(dataLeft["stocked"])
self.view.custom.dataRight = dataRight

```

1. Bind all the coord\_Right components to the custom parameter object members.

* * *

I suspect that most of this routine could be eliminated by disabling the button that calls this event until all the relevant fields have been filled out. Show a red `*` or icon beside each field until it's got a legitimate value and provide a tooltip on the icon to indicate what the problem is.

---

_[View the full topic](https://forum.inductiveautomation.com/t/trouble-with-if-statement-button-event/76892)._
