Hi, I am fairly new to ignition and perspective, so I don’t know if this is a database setup issue or some simple thing I wasn’t aware of:
I am trying to have a simple check in “app” using perspective web browser capabilities. The idea is guests scan a QR code that takes them to the perspective page URL where they input the following:
I have this script right now onAction for my button that references the following named query:
def runAction(self, event):
first = self.getSibling("TextField").props.text
last = self.getSibling("TextField_0").props.text
dep = self.getSibling("Dropdown").props.value
system.db.runNamedQuery("insertCheckin", {
"first_name": first,
"last_name": last,
"department": dep
})
INSERT INTO event_checkins (first_name, last_name, department)
VALUES (:first_name, :last_name, :department)
This setup DOES work when I playtest it in the designer and watch it log into the db using the query browser tool. However when I open an instance in the web browser none of my inputs do anything. The database never gets updated unless I do it locally in the designer.
I don’t know if there are security settings or anything like that so any help identifying this issue would be appreciated.
While this DB log shows the query was actually sent, the gateway logs > STATUS > LOGS will normally have the errors that come back from the database if they occur.
Two checks here (but I think they're irrelevant after your last post while I typed this):
Check that in your named query Authoring tab that the Query Type is set to 'Update' rather than 'Query'.
Check the named query path. The easiest way to avoid errors is to right-click on the named query in Project Browser, Copy Path, and paste that into you system.db.runNamedQuery("<paste here>"...).
Maybe look in Project Browser for a stray script icon (lightning icon) in the view or view components. Is there a chance the view is also reacting to the click.
What's interesting is that it didn’t break when play testing in the designer? Because its the same code and race condition you think it would execute the same? Or is it because in the designer you don’t actually navigate anywhere when you execute a navigation action.
Navigate does nothing in designer, so that would be it.
I would suggest never stacking the event actions in the events, use a piece of script to call the actions you need in order. The named query returns a value when it succeeds, so you can use the return value for error checking as well as enabling the next function to complete.