Database not updating across perspective instances

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.

Have a look in the gateway logs, is there any new entries?

Is this what you mean? I’ll be honest I didn’t know you could look at db logs in the gateway.

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.

1 Like

Ok when I try to checkin on the web browser i get this:
ClientSession 06Oct2025 16:19:05 Received event for missing view "Checkin@C"

My main view is named “Checkin”. Not sure what the @C is.

Two checks here (but I think they're irrelevant after your last post while I typed this):

  1. Check that in your named query Authoring tab that the Query Type is set to 'Update' rather than 'Query'.
  2. 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.

1 Like

Thanks will try that
investigating this as well. I think this is the problem:

edit: Yup got it. Tricky business with events I guess. Thanks guys

That's likely the culprit and fix. It was in the back of my mind slowly percolating to the front.

1 Like

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.

A tip that most of us would recommend:

  • Create custom properties on the view for first, last, and dep.
  • Bind each of the fields / dropdowns to their custom prop.

Now your runAction becomes:

def runAction(self, event):
    system.db.runNamedQuery("insertCheckin", {
        "first_name": view.custom.first,
        "last_name":  view.custom.last,
        "department": view.custom.dep
    })  

This is shorter, easier to read and has the big advantage that your code won't break if you move a component in or out of a container.

2 Likes

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.

1 Like