# Trigger binding AFTER other bindings

**URL:** <https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145>\
**Category:** Ignition\
**Created:** [March 13, 2022, 2:11am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145 "2022-03-13T02:11:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShaneH](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@ShaneH](https://forum.inductiveautomation.com/u/ShaneH)\
**Post date:** [March 13, 2022, 2:11am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/1 "2022-03-13T02:11:27Z")

</div>

Hi-

Using Perspective 8.1.14.

Is there any way to trigger a binding AFTER several other bindings on the page?

I have a single binding that does some slightly complex calculations on the inputs, then runs a generated query in a transform and displays the output in a table.

The inputs to the query come from many input components (mostly dropdowns) on the page which themselves are initialized via bindings.

However, at page load, as each binding on the input components is executed, it triggers the binding which generates the query and updates the table, so the query and table gets updated potentially many times. (It seems to be quite random the binding trigger order).

I would like the generated query and table update to execute last on page load so that the table is only initialized once on page load, and then updated when any of the input components change.

Is there anyway to accomplish this? or some other way to go about this?

Thanks.  
-Shane

---

<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:** [March 13, 2022, 8:02am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/2 "2022-03-13T08:02:47Z")

</div>

Good question! According to answers in these two posts it's not possible.

> [@Disable bindings onStartUp](https://forum.inductiveautomation.com/t/disable-bindings-onstartup/53466/2):
>
> no not possible, you could use an onchangescript tho which can prevent the change from happening with a bit of code, but thats also not quite ideal beter would be to not open the popup on the default value i guess

> [@Dynamically enable or disable a binding in perspective](https://forum.inductiveautomation.com/t/dynamically-enable-or-disable-a-binding-in-perspective/41524/2):
>
> No, but a judicious use of an if / switch / case expression or a transform on the binding could give you a default value.

I'm surprise that the binding's `Enabled` property isn't available in script.

* * *

A possible work around is to put an IF statement into your query's WHERE statement and pass in the query "enabled" as a QueryString variable. In MySQL it looks like this:

```sql
SELECT <field1>, etc.
FROM <tablename>
WHERE IF({enabled} = '1', id > 0, id < 0)

```

I tested this by binding to a toggle switch with this binding:  
`if({../ToggleSwitch.props.selected}, '1', '0')`

In your case you might need to create a property on something with an expression that somehow detects that the dropdowns have been populated.

The binding will probably run once on view load but should be quick if you use a primary key in the IF statement. It will then execute again when the `{enabled}` querystring turns on.

---

<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 13, 2022, 10:27am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/3 "2022-03-13T10:27:20Z")

</div>

I did something like this once by having custom properties monitor the loading state of several components.  
All my bindings went through a script transform, so I added just one line before returning, that looked like this:

```python
self.view.custom.component_x_loaded = True

```

And then I had one more property that I called `view_loaded` and that was bound to all the `component_x_loaded`.  
Then anything that needed to wait for other components to load checked if `view_loaded` was true before doing any calculation.

Now that was several versions ago, so there might be better mechanisms in place now. But it works.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 13, 2022, 10:55am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/4 "2022-03-13T10:55:09Z")

</div>

What if you use an Expression Structure binding and set it to “Wait on All”?

---

<div class="post-metadata">

**Author:** ![ShaneH](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@ShaneH](https://forum.inductiveautomation.com/u/ShaneH)\
**Post date:** [March 13, 2022, 1:02pm UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/5 "2022-03-13T13:02:59Z")

</div>

Thanks.

Using an Expression Structure and “Wait on All” helped significantly, and reduced the number of times the query is triggered on “page load” to two. Still trying to figure that out, but it is much better. It was firing up to 7-8 times previously.

---

<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:** [March 13, 2022, 2:20pm UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/6 "2022-03-13T14:20:47Z")

</div>

> [@pascal.fragnoud](#):
>
> `self.view.custom.component_x_loaded = True`

Do _Perspective_ components have that property?

---

<div class="post-metadata">

**Author:** ![ShaneH](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@ShaneH](https://forum.inductiveautomation.com/u/ShaneH)\
**Post date:** [March 13, 2022, 2:43pm UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/7 "2022-03-13T14:43:55Z")

</div>

It’s under the ‘custom’ section, meaning it’s user added/provided.

---

<div class="post-metadata">

**Author:** ![ShaneH](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@ShaneH](https://forum.inductiveautomation.com/u/ShaneH)\
**Post date:** [March 14, 2022, 4:22am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/8 "2022-03-14T04:22:48Z")

</div>

I spoke to soon. More testing with the Expression Structure approach still seems to trigger the query table update quite often. I’ll try to post an example view demonstrating this.

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [March 14, 2022, 11:57am UTC](https://forum.inductiveautomation.com/t/trigger-binding-after-other-bindings/57145/9 "2022-03-14T11:57:17Z")

</div>

With _Embedded Views_ you can set them to load after the parent view.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e85551f667a00ce2c3e9f8ad670ea272d447ea10.png)  
If you put your table on that view, I’m pretty sure it would load last, after all the other bindings. All your info would have to be passed as parameters though, so it might be much.
