Named query returning empty dataset on table startup

Hi,

So, I have a table in a popup which is supposed to receive the results of a named query, written on startup. I’m receiving an empty dataset but on testing the named query, it runs perfectly. Tried the query binding method, which also worked perfectly but on table’s onStartup, the below script is running but the dataset being returned is empty. Am I missing something?

image

I believe if you turn this logger (it may be a different named query logger hopefully someone knows which) to debug, you will see the named query calls and it’s params logged to the gateway. I would start there to confirm that your parameters are exactly as you expect, there’s no hidden white spaces etc.

Edit: Wait I see this is on a runAction script? Show what extension function/setup you are using exatly here. Not to mention it seems like you are just doing a named query with a param - I don’t see why you shouldn’t do a named query binding on the data property. You can use trim() in an expression to do the same thing as .strip()

1 Like
  1. i’m not going the binding way because i need to update the table on click of a button. so adding a binding would just keep rebinding the table with the dataset.
  2. where do i turn what logger to debug?
  3. This is onStartup for a table

You could utilize this function to log information to the Gateway's wrapper log for debugging

system.util.getLogger | Ignition User Manual

If it’s on button press then doing this on start up makes no sense anyways regardless of the fact that it’s now working now.

What you should do if you want it like this - on button press -

  1. Get the params (PartNumAssemblyCode.strip())

  2. Run the named query

  3. Assign the result to the table data prop.

I wouldn’t do anything in your onStartUp.

Make the table props.data a named query with a hard coded '’ param (or a param that would yield all rows if that’s reasonable I am guessin you are using a LIKE query), and put polling on 0 - so it loads up when the pages loads but is not refreshing.

If you need it to load with a certain subset/param for the NQ but then still only change on button press, make an additional custom proprety initialNQParam that calculates the param you should use for when the table first starts and use that in your named query binding - but keep polling 0 and make initialNQParam static (maybe its a view param or an expression that is non-changing). Then your button press logic handles all subsequent updates.

You can refresh the binding. Just get a reference to the table and call refreshBinding.

2 Likes

I think though he doesn’t want it to auto-refresh which it would do if the param changed right?

1 Like

i hope that video helps to get to know what i’m trying to do..

Why don’t you write out the user story here.

What is the user supposed to do and what exactly do you expect to happen at each step.

which opens this popup -

which is supposed to look like -

where they need to edit each cell, update the db on click of the update button

Since it looks like in the popup the part number/assembly code is disabled (since they picked it from the main view - that makes sense)

image

I 100% would just make the table a named query binding with a parameter bound to trim({path.to.partNo}) and polling 0.

2 Likes

so i got it working with the binding, but i still haven’t figured out why the startup script didn’t return the right result?

Probabbly because the onStartup, fired prior to the parameter resolving to its proper value.

3 Likes