Script transform in perspective table doesn't work anymore when I run a "system.db.runNamedQuery"

I have a table in perspective where the data property is actually bind to a Named Query and I have a script trasform to change the background of specific row depending on columns value.

It works good but now I add a Radio group so to change the values in the table dynamically. In the action performed on the Radio group I add this code:

	if self.props.radios[0].selected:
		
		result = system.db.runNamedQuery("query1")
		self.parent.parent.getChild("FlexTable").getChild("Table").props.data = result
	    
	elif self.props.radios[1].selected:
		result = system.db.runNamedQuery("query2")
		self.parent.parent.getChild("FlexTable").getChild("Table").props.data = result    

what happens is that the table data change correctly, but it looks like the script trasform in the data property doesn't work anymore.

Is "correct" that the binding works in this way and disable the script trasform when I run another namedQuery outside of it? What could I do to avoid this problem?

Thank you

I would make a custom property on the table called customData, have your radio button assign it to that and then in your table data binding make it like

I think your suspicion is right, if you had the data binding a Named Query but in your script you're running this manually assigning data - that transform is likely not running.

If the transform is simple you may consider including it directly in your named query.

1 Like

Transforms only run for values that arrive through the binding, not for assignments.

Thank you all for the reply, I need to figure out how is better to move on.

Consider moving your transform algorithm into a project library script function. Then you can call it from the actual transform (should do this anyways) and also call it after you run the named query from your script.

Make all events and transforms one-liners that delegate to your library.

Ok Phil, I make a test right now.

At the moment I change the query so to accept a boolean parameter so to run a part of the query or another and actually it's working, the problem is that if a change between the 2 radio buttons the data change and even the background (this without the polling rate), if I set a polling when I move through the radio button the data change but the rows background is updated only when the polling rate elapses.

Is this behavior correct?

It is generally unworkable to use a polling binding while also attempting to directly write to the target property by script. Consider using table.refreshBinding('props.data') to deliberately re-run a binding on demand, instead of using polling or scripted query execution.

1 Like

Ok thank you for the reply, I'll work on it