How to update a query tag?

Hello all,

View 1 contains a table bound to a tag with a named query. User selects a record, clicks edit, opens a popup to view/edit the details. User selects the new value to replace the old value, clicks confirm changes, and another tag with a named update query runs.

How do I get the View 1 table data refreshed? It still displays the old values, even with a browser refresh.

Thanks,
Mike

Why would you do that with a tag? Updates are generally done in an action script. The table probably should have the named query directly bound, and then your action script can request a refresh after the update operation completes.

Don't use gateway tags for UI elements, unless you expect the value to be broadcast to all possible clients.

My mistake: View 1's tag is direct bound, using a query statement in the tag itself.

Here is the script on the "Confirm Change" button:

def runAction(self, event):
	# update User table deptID where User ID = XXX to
	# table props selection data[0][''] 
	userID = self.view.params.v_UserID
	deptID = self.parent.parent.getChild("TableContainer").getChild("Table").props.selection.data[0]['ID']
	system.perspective.print(deptID)
	params1 = {"deptid":deptID, "userid":userID}
	namedQuery = "UpdateUserDept"
	system.db.runNamedQuery(namedQuery, params1)

What function would I use to send the update to the DB and then request a refresh?

Ok, you're really close.

Add one more line like so:

	self.getSibling('MyTable').refreshBinding('props.data')

Actually, not a sibling, based on your deptID. More like so:

def runAction(self, event):
	# update User table deptID where User ID = XXX to
	# table props selection data[0][''] 
	userID = self.view.params.v_UserID
	Table = self.parent.getSibling("TableContainer").getChild("Table")
	deptID = Table.props.selection.data[0]['ID']
	system.perspective.print(deptID)
	params1 = {"deptid":deptID, "userid":userID}
	namedQuery = "UpdateUserDept"
	system.db.runNamedQuery(namedQuery, params1)
	Table.refreshBinding("props.data")

What's another way to not use a tag for an update query?
something like:

system.runCode "UPDATE statement..."

What if I put the refresh statement in the script calling the popup view? Would it run all the code before the popup loads or would it wait for the popup to close then resume running the script?

You aren't using a tag for your update query. And you said your table is directly bound to the select named query. So, no tag involved. You're good.

Wait. You said your tag is direct bound to the named query. You must be confused, because that isn't supported.

Eww. Unless it is a client tag. Those cannot be directed to refresh. Don't bind queries to client tags. Just bind the table's data to the named query.

Lol.

The primary table, View 1, is bound to a query tag.

the popup view allows the user to change some value, use a TAG connected to a Named Query, to update the table data.

Close the popup, the changes are not realized on View 1.

Refresh the table on the server and I can see the update was made.

Also... I added a refresh binding script after the call to open the popup but that didn't refresh the View 1 data.
Popup action: from View 1

Script action:
image

didn't work.

From the popup confirm change button action:

When I create tags in the designer, these are considered client tags?

Done. So a change script or refresh is still needed looks like.

No, only tags created in the Vision Client Tag provider. Such tags are per-client at runtime, and are commonly used to hold client-wide (but not system-wide) state.

System-wide state is held in gateway tags (the default and other real-time providers). UI data should not go through gateway tags unless it is so commonly displayed on all/most clients that broadcasting efficiently via tag makes sense.

Yes, unless the binding is set to polling. But that burns CPU on gateway and DB to no purpose in most cases. Use .refreshBinding() when you know the data has changed (because you just changed it, typically).