# Refresh table from \[shared\] Script Library or from tag change event

**URL:** <https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898>\
**Category:** Ignition\
**Created:** [February 6, 2018, 11:09pm UTC](https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898 "2018-02-06T23:09:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian.kehn](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@brian.kehn](https://forum.inductiveautomation.com/u/brian.kehn)\
**Post date:** [February 6, 2018, 11:09pm UTC](https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898/1 "2018-02-06T23:09:19Z")

</div>

I have a shared script that finishes with a db update.

```
   system.db.runPrepUpdate(query,args,"IgnitionTables")

```

I’d like to add the following lines to refresh my ignition table’s values after updating my sql db.

```
window = system.gui.getWindow('Main window')
table = window.rootContainer.getComponent('Table 1')
system.db.refresh(table, 'data')

```

But I get an error that the object ‘gui’ is not found. I assume that my shared script simply doesn’t know what project to look in for the specified window. I also have tried adding a memory tag that I turn on when the shared script is finished (basically a handshake), and then adding a tag event script to it which would again include:

```
window = system.gui.getWindow('Main window')
table = window.rootContainer.getComponent('Table 1')
system.db.refresh(table, 'data')

```

but that also didn’t work. What is the best way to refresh my table each time my [shared] script finishes?

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [February 6, 2018, 11:36pm UTC](https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898/2 "2018-02-06T23:36:50Z")

</div>

I think your tag handshake might work, but your issue is system.gui is only available within a Client scope, not from the Gateway where tag change event scripts run. Making your tag a client tag might help, but then you need to update each clients copy from the Gateway.

I think you should call your shared script from a Gateway Event Script, and when it’s finished you can send out a message to all clients using [system.util.sendMessage](https://docs.inductiveautomation.com/display/DOC79/system.util.sendMessage). You’d then need a Client Message Handler to receive that message and update the table.

---

<div class="post-metadata">

**Author:** ![brian.kehn](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@brian.kehn](https://forum.inductiveautomation.com/u/brian.kehn)\
**Post date:** [February 7, 2018, 12:42am UTC](https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898/3 "2018-02-07T00:42:56Z")

</div>

I attempted to write to a client tag from a [shared] script but was unsuccessful. I’ll try your suggestion of “system.util.sendMessage”. Thanks for the support.

---

<div class="post-metadata">

**Author:** ![johnplutz](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@johnplutz](https://forum.inductiveautomation.com/u/johnplutz)\
**Post date:** [June 23, 2020, 4:11pm UTC](https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898/4 "2020-06-23T16:11:53Z")

</div>

# this worked for me

# project.projFuncs.refresh\_all() # how to call this function

def refresh\_all():  
try:  
window = system.gui.getWindow(‘Window\_Name’)

```
	system.db.refresh(window.getRootContainer().getComponent('Table1'), 'data')
	system.db.refresh(window.getRootContainer().getComponent('Table2'), 'data')
	system.db.refresh(window.getRootContainer().getComponent('Field Intro'), 'data')
	
except ValueError:
   system.gui.warningBox("Failed to Open Barcode Recipes Window")

```

# this interface mangled the formatting so you’ll have to adjust that

---

<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:** [June 24, 2020, 1:58am UTC](https://forum.inductiveautomation.com/t/refresh-table-from-shared-script-library-or-from-tag-change-event/16898/5 "2020-06-24T01:58:25Z")

</div>

> [@johnplutz](#):
>
> this interface mangled the formatting

Well, it did the best it could without a hint about what is code and what is not. Place code markers by using the "Preformatted text" button while your code is highlighted. Or place three back-quotes (these ```) on a line above and again on a line below your code. It should look like this:

```  
My pasted code  
```
