# Perspective custom element binding dataset refresh based on an OPC tag

**URL:** <https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [September 23, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896 "2025-09-23T16:10:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 23, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/1 "2025-09-23T16:10:24Z")

</div>

Hello,

I have a Perspective view with a custom prop called Key which has named query binding pulling a dataset to display data on the view. One pallet slot holds 5 at a time. As the operator builds the next slot parts, the display data gets updated. Currently I am using absolute poll rate.

I want to use a tag value change script to refresh the query on ‘Key’ based on a OPC tag which increments for every part. If there is no change in the counter, I wouldn’t refresh thereby saving gateway some load. Is this achievable via a script? Or any other more suitable way?

Thanks

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 23, 2025, 4:16pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/2 "2025-09-23T16:16:49Z")

</div>

With a script you can use `[path-to-component].refreshBinding([property-name])`

Note that if the incrementing OPC tag value happens to be a parameter to the named query, then a change in it would automatically cause the query to refresh.

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 23, 2025, 5:34pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/3 "2025-09-23T17:34:31Z")

</div>

I have entered the following in the tag change script and it gives me a syntax error -’no viable alternative at input 21’ at Sta 21 User

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
    [Sta_31_21_Interface/Sta 21 User/Sta 21 Interface].refreshBinding([key_3])

```

ProjectName/FolderName/ViewName and key-3 is the custom prop with query binding.

Not sure what I am doing wrong here. Thanks @Ryan_Deardorff

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 23, 2025, 5:39pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/4 "2025-09-23T17:39:24Z")

</div>

> [@Sweetz](#):
>
> tag change script

Is this a tag's Value Changed script or a gateway Tag Change Event script? Either way, you'll need to use `system.util.sendMessage` to send a message targeting any active session of the project with the view containing the binding.

` system.util.sendMessage("Target Project", "refreshData", {}, scope="S")`

Then have a Perspective Session Message handler defined in that project that re-echoes the received message to the active session using `system.perspective.sendMessage` with a scope of `session`.

`system.perspective.sendMessage("refreshData", {}, scope="session")`

From there, your view with the binding should have a message handler that will call `refreshBinding` on the associated object property.

`self.view.refreshBinding("custom.key_3")`

The other option would be to bind the target tag to a custom property on the view with the data binding and write a property Changed script to call `refreshBinding` on the data binding(@Ryan_Deardorff beat me to it).

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 23, 2025, 5:44pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/5 "2025-09-23T17:44:38Z")

</div>

I was thinking of a change script on a custom property that is bound to the tag, not a tag event change script.

Suppose your dataset is a custom view property `data`. You have another custom view property that is bound to the value of the OPC tag, and a change script on that:

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	self.refreshBinding("custom.data")

```

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 23, 2025, 5:49pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/6 "2025-09-23T17:49:44Z")

</div>

This is a tag value change from the tag browser.

@Ryan_Deardorff I am using a lookup function on the dataset in key\_3 to populate the fields on the view

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 23, 2025, 5:53pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/7 "2025-09-23T17:53:37Z")

</div>

I will try this during downtime. Thanks @ryan.white

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 23, 2025, 6:18pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/8 "2025-09-23T18:18:53Z")

</div>

I just tried this method @Ryan_Deardorff . It works great. Defined a custom prop with the OPC binding right under key\_3 and ran change script on the new prop with a self.refreshBinding("custom.key\_3") and it’s updating the dataset automatically. Thanks

Will have to try @ryan.white solution later. It’s interesting too

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 23, 2025, 8:19pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/9 "2025-09-23T20:19:12Z")

</div>

Glad I could help.

I also recommend assigning meaningful names to your properties. I inherited a project where my predecessor left a bunch of unnamed ('key', 'key\_1', etc.) properties, and found it frustrating trying to figure out what their purpose was. I've said the same about view component names--a little extra effort in the short term can save lots of hassle in the long run.

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 24, 2025, 1:23pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/10 "2025-09-24T13:23:42Z")

</div>

True..I inherited this with no knowledge of Ignition and first thing I will do is cleanup after I figure some things out.

---

<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:** [September 24, 2025, 3:38pm UTC](https://forum.inductiveautomation.com/t/perspective-custom-element-binding-dataset-refresh-based-on-an-opc-tag/110896/11 "2025-09-24T15:38:21Z")

</div>

> [@Sweetz](#):
>
> Will have to try @ryan.white solution later

While this will work, I would recomend not going this route unless you have many such things to refesh at once. @Ryan_Deardorff's method is the more maintainable option.
