Issue with refreshing a dataset of a table in script

I have the following script in the click event of a button to refresh the data in a table

    table=self.getSibling("Table1")
system.db.refresh(table, "data") 

I see the following error in the Gateway logger.

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 13, in runAction AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘refresh’

at org.python.core.Py.AttributeError(Py.java:207)

at org.python.core.PyObject.noAttributeError(PyObject.java:1032)

at org.python.core.PyObject.getattr(PyObject.java:1027)

at org.python.pycode._pyx51.runAction$1(:13)

at org.python.pycode._pyx51.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:171)

at org.python.core.PyBaseCode.call(PyBaseCode.java:308)

at org.python.core.PyFunction.function___call__(PyFunction.java:471)

at org.python.core.PyFunction.call(PyFunction.java:466)

at org.python.core.PyFunction.call(PyFunction.java:456)

at org.python.core.PyFunction.call(PyFunction.java:451)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:674)

at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:790)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:82)

at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:64)

at com.inductiveautomation.perspective.gateway.action.ActionDecorator.runAction(ActionDecorator.java:18)

at com.inductiveautomation.perspective.gateway.action.SecuredAction.runAction(SecuredAction.java:39)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:257)

at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:246)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:215)

at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 13, in runAction AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘refresh’

… 27 common frames omitted

system.db.refresh() is a Vision client only command. To perform the equivalent in Perspective, just use someComponent.refreshBinding("path") - the component can be any component reference, and path is just the path to the particular property.

4 Likes

Thanks for your suggestion. It worked. Here is what I did,

table=self.getSibling(“Table1”)
table.refreshBinding(“props.data”)

2 Likes

Paul, can you talk to the documentation team and have them add someComponent.refreshBinding("path") to the user manual? I searched for refreshBinding, but it found nothing. The tool is incredibly helpful!

Let’s say the binding is to a named query with caching enabled. Is there a way to refresh the binding and force it to bypass caching? I noticed that is an option in the binding itself. This would be helpful if I a table displaying the content of a database table along side a form that is used to update a record in the table.

Not at present, although you could use system.db.clearNamedQueryCache() to invalidate the cache.

That worked perfectly! Thank you!

I’m now running into an issue in my project after I moved my view to a global project. My project now inherits this view from the global project. For some reason the cache no longer clears and I’m not getting any errors in the log. Thoughts?

Please elaborate it with an example. I didn’t follow, someComponent? and “path”?. I am having a similar problem in perspective where I have the following components - cooordinate container, a label, a hyperlink, a table component (the contents needs to be refreshed after certain action) and a date input component.

You provided more information, but not enough for me to tell you how to actually solve your problem.

You need to start from a reference to whatever component has the binding you want to re-run. You can use the property selector helper in the script editor to get one - just select a property and remove the end of the path.

And “path” is just the path to the property that contains the binding. Such as props.value for a simple case like a text field, or props.data for a table’s main data property.

Thanks, I am able to refresh it now

1 Like