RunNamedQuery with parameter not returning results along with unknown type code warning

I have two named queries
Last30DaysDowntime (contains a string parameter named plant)

Last30DaysNoParam (same query as Last30DaysDowntime but with no parameter)

Both named queries when tested on their own run successfully.

I have a table with a onRowDoubleClick action script that executes the named queries [Last30DaysDowntime] or [Last30DaysNoParam] on a TimeSeriesChart. The double click gets a location/plant from the table, which is used as the parameter in named query [Last30DaysDowntime].

The onRowDoubleClick action script produces results successfully in object TimeSeriesChart if I run the named query with no parameters [Last30DaysNoParam]

location = event.value["Location"]
params = {"plant":location}
self.getSibling("TimeSeriesChart").props.series[0].data = system.db.runNamedQuery("Last30DaysNoParam", {})

If I run the named query that has the parameter [Last30DaysDowntime] I do not get any results, along with an unknown type code warning.

	location = event.value["Location"]
	params = {"plant":location}
	self.getSibling("TextField").props.text = params 
    self.getSibling("TimeSeriesChart").props.series[0].data = system.db.runNamedQuery("Last30DaysDowntime",params)

If I do a print (system.perspective.print(location)), the location parameter is printed successfully.
If I setup a textfield and write the parameter to the textfield (see the following code), it shows the {“plant”;“CEW”} in the text field in the image above:

location = event.value["Location"]
params = {"plant":location}
self.getSibling("TextField").props.text = params 

Question(s): What is causing the named query with the parameter to not return results? How do I get rid of the unknown type code when the parameter is used in the RunNamedQuery?

The variable in the named query has a capital P (Plant). You are passing in lowercase. (plant)

2 Likes