Perspective button Event Configuration not working

I am new to Perspective after working in Vision. I have a button on a Perspective popup view that is designed to execute a named query and then close the popup. The named query ("Clear Replacements Table") empties a table in the database.

When I have just the script event configured on the action, it works fine. When I have both the script event and the popup event configured, it closes the view but doesn't run the query. I have tried organizing the actions both ways - once with the script event running first, once with the popup event running first. This did not impact the results.

I attached screenshots of my configurations. Any support would be great! Thank you

Script event configuration:

Popup event configuration:

I seem to remember this coming up before in the forum.
Try closing the popup in the script rather than in a separate action.

Tip: remove the Vision tag from your question. It is nothing to do with Vision.

1 Like

Assuming "Clear Replacements Table" is the path of your named query:

system.db.runNamedQuery(system.util.getProjectName(), "Clear Replacements Table" )

Remember to Save *

1 Like

Actions configured for an Event run asynchronous, so there is no guarantee as to when each will complete. There's a very good chance the closing of the Popup occurs before the query script completes. If you need guaranteed synchronous behaviors, you must put everything into a single script Action.

In general, the only time you should configure multiple Actions off of a single Event is when there is no distinct order in which the Actions begin or complete.

2 Likes

Closing the popup within the script worked. Good to know about the asynchronous timing! (Working code pasted below)

def runAction(self, event):
	system.db.runNamedQuery("Clear Replacements Table")
	system.perspective.closePopup('')