Vision scripting issue

Hello,
I am trying to perform delete operation in a table using database and script.
I am trying to call a named query through scripting, but there's an error saying Transaction databaseName is closed
If I try to include the args as list, I will get another error saying Cannot coerce value '[{'sensor_id': 12}]' into type: interface java.util.Map

Can you please help me out with this issue

table = event.source.parent.getComponent('Table')
selectedRow = table.getSelectedRow()

if selectedRow >= 0:
data = (table.data).getValueAt(selectedRow, 'sensor_id')

# Ask for confirmation
confirmed = system.gui.confirm("Are you sure you want to delete the selected row?")
if confirmed:
    args = {'sensor_id': data}  # Using a dictionary for named parameters
    event.source.parent.getComponent('Label').text = str(selectedRow) + str(data)

    # Delete from database using the named query
    query = "displayDeleteUser"
    result = system.db.runNamedQuery("displayDeleteUser", args, "databaseName")

    system.db.refresh(event.source.parent.getComponent('Table'), "data")
else:
    print("Deletion cancelled.")

else:
system.gui.errorBox("Please Select a Row to Delete", "Selection Error")

Well... You're just not using the function properly.

Look at the doc:
https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery

The function's third argument is either tx or parameters, depending on the scope.
From the error you're getting, it is clear that you're calling the function in the client/session scope, and that it expects the third argument to be a transaction id.
Remove the third argument and you'll be fine.

PS: the database used by named queries are defined by the named query itself, not by the function that calls it.
PPS: Try to find a better title next time. This one says absolutely nothing about the issue you have: 2 out of the 3 words are already in the tags, and the last one, well... you probably wouldn't be posting if everything was fine.

See here on how to post code on the forum. (The first four lines of code are not formatted properly.)

There's a pencil icon under your post which will allow you to edit it - and fix the title.

Thank you! It is working now!

And apologies for title which is used!

Thank you!
Will have a look at it and post it properly the next time!