# Update table data populated from a script - best practice

**URL:** <https://forum.inductiveautomation.com/t/update-table-data-populated-from-a-script-best-practice/66734>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [November 21, 2022, 4:27am UTC](https://forum.inductiveautomation.com/t/update-table-data-populated-from-a-script-best-practice/66734 "2022-11-21T04:27:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [November 21, 2022, 4:27am UTC](https://forum.inductiveautomation.com/t/update-table-data-populated-from-a-script-best-practice/66734/1 "2022-11-21T04:27:05Z")

</div>

We are using the Sepasoft SPC module, however this question is really about general Ignition functionality around it, so it feels appropriate to post here.

We have a perspective view containing a table to display upcoming samples. The table data is bound to a location property and then a script transform is applied to run a sepasoft script which returns a dataset containing a list of samples.

The issue we have run into with the script transform is there seems to be no good way to make the table update when new samples are generated from the SPC module. In the sepasoft 'sample due' event script I have included the following:

```auto
system.util.sendMessage('SPC_proj','SampleUpdate',scope="S")

```

I then have a 'SampleUpdate' session event message handler which sets a session property:

```auto
session.custom.sampleUpdate = True

```

On the view containing the table I have a label whose text property is bound to the the 'sampleUpdate' session property, and the text property has an change script which resets the custom session prop and sends another message:

```auto
system.perspective.sendMessage('TableUpdate')
self.session.custom.sampleUpdate = False

```

And my table then has a TableUpdate message handler to refresh its data binding.

This all works but it seems like a particularly clunky way to go about things. What is the best way to refresh a component binding other than a message handler which by design needs to come from another component?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/43c91f1964e89c8ffdb35492f5553e6c8d567d60.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 21, 2022, 2:44pm UTC](https://forum.inductiveautomation.com/t/update-table-data-populated-from-a-script-best-practice/66734/2 "2022-11-21T14:44:38Z")

</div>

Your verbiage suggests you **aren't** using your table's [.refreshBinding()](https://docs.inductiveautomation.com/display/DOC81/Perspective+Component+Methods#PerspectiveComponentMethods-RefreshingBindings) method to trigger re-execution of your `data` binding. You haven't provided any code that does, so I think not. That's probably your answer.

If the update from Sepasoft is supposed to be global, consider using an integer gateway tag as your UI trigger, and simply increment it. On your table, include a custom property bound to this tag, and attach an `onChange` event to it that calls `self.refreshBinding('data')`. I suspect you will find that architecture easier to reason about than messaging.

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [November 21, 2022, 9:39pm UTC](https://forum.inductiveautomation.com/t/update-table-data-populated-from-a-script-best-practice/66734/3 "2022-11-21T21:39:18Z")

</div>

I am using refreshBinding() and the existing set up works, I was simply looking for a neater solution.

I don't love the idea of a hardcoded global tag path in a custom sepasoft script but it does appear to be the best option.
