# Refreshing Power table-Vision

**URL:** <https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [September 27, 2022, 11:45am UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522 "2022-09-27T11:45:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 27, 2022, 11:45am UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/1 "2022-09-27T11:45:09Z")

</div>

Hi,

I have designed a power table as below,

the table will be loaded once load button is clicked.  
And on right clicking the row, i have written onPopuptrigger to open a popup window.

```auto
def onPopupTrigger(self, rowIndex, colIndex, colName, value, event):
	# Example for displaying a popup menu:
	self.parent.LossScreen = True
	iStart = self.data.getValueAt(self.selectedRow, 0)
	iEnd = self.data.getValueAt(self.selectedRow, 1)
	iProcess = self.parent.Process
	iMachineID = system.tag.readBlocking("[client]MachineNo")[0].value
	self.parent.LossScreen = True
	params={"iStart":iStart,"iEnd":iEnd,"iProcess":iProcess,"iMachineID":iMachineID}
	window=system.nav.openWindow("Main Windows/Machine/Update BreakDown Reason",params)
	system.nav.centerWindow(window)

```

Popup Window,

In this window, i will be updating the breakdown reason for the machine. I would like to refresh the table once the save button is clicked.  
Save Button :  
`iStart=event.source.parent.iStart  
iEnd= event.source.parent.iEnd  
iProcess=event.source.parent.iProcess  
iMachineID= system.tag.readBlocking(“[client]MachineNo”)[0].value  
vReason = event.source.parent.getComponent(‘Group 4’).getComponent(‘orderNo’).text  
params ={“vStart”:iStart,“vEnd”:iEnd,“vMachineID”:iMachineID, “vReason”:vReason}

system.db.runNamedQuery(“MachineBoard/updateBreakDown”,params)  
system.gui.messageBox(“Breakdown reason updated”)

window = system.gui.getWindow(‘Main Windows/Machine/Loss Time’)  
dataTable = window.getRootContainer().getComponent(‘Power Table’)  
system.db.refresh(dataTable, “data”)  
system.nav.closeWindow(“Main Windows/Machine/Update BreakDown Reason”)`

But currently, the table is not updating unless i reload the page. Am i missing something?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 12:13pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/2 "2022-09-27T12:13:27Z")

</div>

> [@8.02 system.gui.messageBox Functionally](https://forum.inductiveautomation.com/t/8-02-system-gui-messagebox-functionally/26665/2):
>
> `system.gui.messageBox` is a _modal_ interrupt - meaning that it blocks everything on the ‘Event Dispatch Thread’ (a Java Swing UI concept). _All_ script handling will be interrupted, unless you’ve specifically created an asynchronous thread before calling your message box.

Try removing the `system.gui.messageBox` or moving it to the end of the script. Nothing about your script looks wrong from what I can tell.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 27, 2022, 12:17pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/3 "2022-09-27T12:17:02Z")

</div>

No. Still it is not working!

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 12:26pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/4 "2022-09-27T12:26:17Z")

</div>

Are you sure your path to the power table correct? Is it in the root container and not in a group?

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 27, 2022, 12:27pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/5 "2022-09-27T12:27:01Z")

</div>

Yes i think so.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/9529c340ced1060ea71c9e21119a69a7f2446e53.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 12:29pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/6 "2022-09-27T12:29:26Z")

</div>

> [@Dharani\_T](#):
>
> system.db.runNamedQuery(“MachineBoard/updateBreakDown”,params)

Maybe check and see if you're query is working as intended

```auto
update = system.db.runNamedQuery("MachineBoard/updateBreakDown",params)
print update

```

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 27, 2022, 12:31pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/7 "2022-09-27T12:31:15Z")

</div>

Query is wokring. Because when i reload , table is updated Where can i see the printed value??

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 12:32pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/8 "2022-09-27T12:32:02Z")

</div>

Tools → Console (ctrl + shift + C)

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 27, 2022, 12:33pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/9 "2022-09-27T12:33:46Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d791d3508dee88580c64e7b3cbcf8b859663a89c.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 12:34pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/10 "2022-09-27T12:34:59Z")

</div>

make sure your script is using `"` straight quotes and not curly ones `“`

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 27, 2022, 12:35pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/11 "2022-09-27T12:35:25Z")

</div>

Yes, I have changed.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 12:50pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/12 "2022-09-27T12:50:21Z")

</div>

I don’t see anything else. I’ve tried this in a designer from a script console and it works. 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 27, 2022, 1:00pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/13 "2022-09-27T13:00:47Z")

</div>

It seems redundant, but you could add a `system.db.refresh(dataTable, “data”)` to the primary window’s internalFrameActivated event handler, so it refreshes the table when it regains focus after the popup closes.

I’m just not seeing the actual problem with the code.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 1:05pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/14 "2022-09-27T13:05:52Z")

</div>

Either that or maybe invoke later?

```auto
iStart=event.source.parent.iStart
iEnd= event.source.parent.iEnd
iProcess=event.source.parent.iProcess
iMachineID= system.tag.readBlocking("[client]MachineNo")[0].value
vReason = event.source.parent.getComponent("Group 4").getComponent("orderNo").text
params ={"vStart":iStart,"vEnd":iEnd,"vMachineID":iMachineID, "vReason":vReason}

system.db.runNamedQuery("MachineBoard/updateBreakDown",params)
# system.gui.messageBox("Breakdown reason updated")

def refreshTable():
   window = system.gui.getWindow("Main Windows/Machine/Loss Time")
   dataTable = window.getRootContainer().getComponent("Power Table")
   system.db.refresh(dataTable, "data")

system.util.invokeLater(refreshTable)
system.nav.closeWindow("Main Windows/Machine/Update BreakDown Reason")

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 27, 2022, 1:13pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/15 "2022-09-27T13:13:36Z")

</div>

Does the named query use any caching? What’s the logic on the `Load` button - perhaps it is clearing the named query cache before reloading the table.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 27, 2022, 1:14pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/16 "2022-09-27T13:14:01Z")

</div>

Will the event handler complete the invoke later after its window has closed?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 27, 2022, 1:15pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/17 "2022-09-27T13:15:19Z")

</div>

I’m not sure.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 27, 2022, 1:17pm UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/18 "2022-09-27T13:17:48Z")

</div>

Perhaps the problem is that the nav close is firing before the refresh has completed. Perhaps the nav close should be invoked later to delay the thread termination a bit.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 28, 2022, 4:30am UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/19 "2022-09-28T04:30:24Z")

</div>

No .it is not working as expected.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [September 28, 2022, 4:30am UTC](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522/20 "2022-09-28T04:30:41Z")

</div>

Script in Load button:

```auto
event.source.parent.getComponent('Label').visible = True
event.source.parent.getComponent('Label').text ="LOADING..."
event.source.parent.stDate =event.source.parent.getComponent('Group').getComponent('stDate').date
event.source.parent.endDate =event.source.parent.getComponent('Group').getComponent('endDate').date
vData=event.source.parent.getComponent('Power Table').data
def checkValue():
	if vData!= None:

		event.source.parent.getComponent('Label').visible = False
	else:
		event.source.parent.getComponent('Label').visible = True
		
system.util.invokeLater(checkValue,5000)

#MachineBoard/getProductionData
vProcessArea = event.source.parent.Process
vStartDate = event.source.parent.getComponent('Group').getComponent('stDate').date
vEndDate = event.source.parent.getComponent('Group').getComponent('endDate').date
vEqId = event.source.parent.MachineNo
vMinutes = event.source.parent.getComponent('Group').getComponent('Dropdown').selectedValue
params = {"iProcessArea":vProcessArea, "SDate":vStartDate, "EDate":vEndDate , "iEqId":vEqId,"iMinute":vMinutes}
#params = {"iProcessArea":vProcessArea, "iEqId":vEqId,"iMinute":vMinute}
#get data in a data set
#run named query
dataSet = system.db.runNamedQuery("MachineBoard/getLossTime", params)

#bind data set to table
#event.source.parent.parent.getComponent('Table').data= dataSet
event.source.parent.getComponent('Power Table').data= dataSet

if dataSet.getRowCount()==0:
	
	event.source.parent.getComponent('Label').text ="NO DATA AVAILABLE..."

```

[Next page](https://forum.inductiveautomation.com/t/refreshing-power-table-vision/64522.md?page=2)
