# Best way to update a table that was created dynamically from an event script

**URL:** <https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 26, 2024, 8:06pm UTC](https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831 "2024-01-26T20:06:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ltoscano](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@ltoscano](https://forum.inductiveautomation.com/u/ltoscano)\
**Post date:** [January 26, 2024, 8:06pm UTC](https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831/1 "2024-01-26T20:06:13Z")

</div>

Hi Everyone,

I'm struggling with the best way to program the functionality I'm looking for here.

Using perspective, I have a Dropdown component, that gets it's data from a SQL database. The list is a list of Equipment Groups.

When the user selects an Equipment Group from the list, the onActionPerformed event fires, and I run a script that takes a look at all the HOA tags I have under the folder of that name that matches the value prop of the dropdown. All good so far.

In the same script, I then dynamically build a list of tags and stuff it into a table using the data prop. Again all works beautifully.

Now the user can select a row, and that will let me call a popup for that particular tag and change the state of the HOA. Still working great.

Now what I want to happen, is when I close that popup, I want the underlying data on the table to update. Since the actual table data did not actually change (because its a static list I built dynamically) there's no way to just refresh it. I have explored various ways of trying to get the dropdown to reactivate but none work and it seems "unclean".

I'm sure there's a good way to do this. I know I'm close and I'm just not thinking of something. Anybody have a better way of doing what I'm doing?

Thanks in advance!

---

<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:** [January 26, 2024, 8:15pm UTC](https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831/2 "2024-01-26T20:15:23Z")

</div>

Put the script from on 'OnActionPerformed' event into your project's script library. Then call it from the 'onActionPerformed' (passing the required data from whatever properties).

You can then re-use this script call in a messageHandler, either on the table or the root container of the view. Send a message via `system.perspective.sendMessage()` right before closing the popup to trigger the rebuild.

As an added bonus this will make your action performed and message handler scripts much smaller/cleaner.

If you ever run into the case of 'I want the logic from button x to also be able to be triggered from button/component y`, put the main logic into a project library script and then call it from the respective locations.

---

<div class="post-metadata">

**Author:** ![ltoscano](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@ltoscano](https://forum.inductiveautomation.com/u/ltoscano)\
**Post date:** [January 26, 2024, 8:46pm UTC](https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831/3 "2024-01-26T20:46:50Z")

</div>

Ah ha! Yes thank you Ryan that sounds like the piece I'm missing.

Currently on the last line, my scrip stuffs the dataset right into the table `self.getSibling('mytable').props.data = tableData`

I assume this isn't going to work like written so do I need a different way to stuff the data into the table right from the script OR would I pass the dataset back to the calling code and have it stuff the data?

---

<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:** [January 26, 2024, 8:49pm UTC](https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831/4 "2024-01-26T20:49:18Z")

</div>

> [@ltoscano](#):
>
> pass the dataset back to the calling code

Do this

---

<div class="post-metadata">

**Author:** ![ltoscano](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@ltoscano](https://forum.inductiveautomation.com/u/ltoscano)\
**Post date:** [January 31, 2024, 4:57pm UTC](https://forum.inductiveautomation.com/t/best-way-to-update-a-table-that-was-created-dynamically-from-an-event-script/84831/5 "2024-01-31T16:57:01Z")

</div>

Ryan - Just wanted to return and say thanks. This worked perfectly. Took me a little to fiddle with the right syntax to pass the data set back over but once I figured that out this worked exactly as I needed. Thanks much!
