Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
AKN
Partner - Contributor III
Partner - Contributor III

Field API SelectValues method check if result exist

I'm using Field API to filter some tables. However if the value I'm filtering doesn't exist it returns all of the results in the table. I want it to show a message like "no results" or whatever it doesn't matter. How can I achieve this?

 

app1.field("testFilterID").selectValues(["test"], false);

 

Labels (3)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Hey @AKN , for achieve this you cannot directly use Field API, I've tested and there is no response for values not available. What you can do is to create a listbox using Engine APIs, search your value into the list box data using SearchListObjectFor Engine API method, perform GetLayout method and check if your ListBox has values. This allows you to check if the value exists in all field values.

View solution in original post

4 Replies
alex_colombo
Employee
Employee

Hey @AKN , for achieve this you cannot directly use Field API, I've tested and there is no response for values not available. What you can do is to create a listbox using Engine APIs, search your value into the list box data using SearchListObjectFor Engine API method, perform GetLayout method and check if your ListBox has values. This allows you to check if the value exists in all field values.

AKN
Partner - Contributor III
Partner - Contributor III
Author

Thanks! I will look into it.

AKN
Partner - Contributor III
Partner - Contributor III
Author

Okay so I have a data like this:
CustomerID, Quantity
CST1,           35
CST1,           12
CST100,       35
CST30,         20

customerID is mandatory and quantity is optional. I'm filtering like this:

 

app.field(customerFilterID).selectValues(["CST1"], false);
app.field(quantityID).selectValues(["35"], false);

 

AKN_0-1727443651480.png

shows a table that only has CST1 and 35 as Quantity, that's ok.

 

app.field(customerFilterID).selectValues(["CST1"], false);
app.field(quantityID).selectValues(["20"], false);

 

AKN_1-1727443729878.png

shows a table that has CST30 which I didn't select, and 20 as Quantity, that's not ok.

Toggling from false to true also didn't work.

AKN
Partner - Contributor III
Partner - Contributor III
Author

This is kind of important so any help is appreciated.