Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

ikomlyakov1929
New Contributor III

How to use Expression in "searchResults" method (App API)?

Hi,

I'm trying to implement search and filter functionality for my extension. For this purpose I'm using searchResult method.

As I understand this method could search by field in the model, but not by expression.

So the question is: How to search by Expression with help of API?

(For example: we have we have following fields in the model: UserName, ChildrenCount.

I want to search by field =if(not IsNull(ChildrenCount) or ChildrenCount = 0, UserName))

Thanks

1 Solution

Accepted Solutions
alextimofeyev
Contributor II

Re: How to use Expression in "searchResults" method (App API)?

Hi Ilya,

we've used selectMatch method to accomplish searching by expression to select values in a field.

Alex

4 Replies
alextimofeyev
Contributor II

Re: How to use Expression in "searchResults" method (App API)?

Hi Ilya,

we've used selectMatch method to accomplish searching by expression to select values in a field.

Alex

ikomlyakov1929
New Contributor III

Re: How to use Expression in "searchResults" method (App API)?

Hi Alex,

Thank you for answer.

I've tried Field API, but faced the trouble that It does not filter values if the expression is not single field like 'UserName' but the one that I noticed before. Here is my code (I removed class names to make it readable):

     var myfield= app.field(fields).getData(); // <-- this works well

     myfield.OnData.bind( function() {

          myfield.rows.forEach( function(row, i) {

               $element.find("ul").append("<li data-index='" + row.qElemNumber + "'>" + row.qText + "</li>");

          });


          $element.find("li").click( function() {

               app.field(fields).select([$(this).data("index")], true, true); // <-- this method does not work for field like "=if(...)"

          });

     });

Thanks

Ilya

alextimofeyev
Contributor II

Re: How to use Expression in "searchResults" method (App API)?

In your example, were you trying to limit the values in field UserName to those for which the condition of ChildrenCount = 0 or null is true?

ikomlyakov1929
New Contributor III

Re: How to use Expression in "searchResults" method (App API)?

This is an example of expression that I would like to use for filtering. It could be the different type of "if" like expression.

Actually I found the walk around for this issue. Found how to have an ability to search with search suggestions, how to search and select by expression fields. That is something that i need to avoid using APP API search methods.

Thanks.

Community Browser