Perspective system.db.runNamedQuery not writing all data variables

I can run the named query inside testing and all data fields populate. If i run it from a button with event onClick, only 4 of the data fields are written to the database, and the other 4 come back null.

script from the button

results in mysql

Any ideas what I’m doing wrong? Its a simple form, then takes the data entered and inserts into the db.

Simplest thing to try: Make sure that your values are actually populated and not null; e.g.:
print ticketnumber right before the runNamedQuery call.

1 Like

The form has data in each field, just not sure why it would not retrieve the value with the script and pass to the NamedQuery. Does the syntax look correct in the script? Not sure what I’m missing.

Oh, hah.

Your parameter names don’t match up, e.g. on the named query it’s ticket (per your screenshot) but it’s ticketnum in your script.

1 Like

I made sure they all match and I’m still receiving null values from the script. Very odd it will take some fields but not others.

Do you have any triggers on the database table that might be resetting these values on the db end on insert? Worth a look.

No triggers that I am aware of. Here is detail of the simple table.

Ok, try doing another sample but

system.perspective.print(params) right before your runNamedQuery and show us what you get in your print statement and then show us what the record is in the database.

With MySQL you would see any triggers under the table in the object explorer like this -

Okay, Ignition tech support resolved my issue. Turns out I was using my db column name in the script instead of the named query parameter name. The few fields that matched were lucky enough to pass through. Issue resolved when I changed the params = { “namedquery name”: ‘script variable’ }