Skip to main content
1-Visitor
August 25, 2016
Solved

LikeFilter syntax for multiple patterns?

  • August 25, 2016
  • 4 replies
  • 8759 views

Hi all,

I'm trying to use the LikeFilter infotable function to filter some results in an infotable. I'm using the basic syntax like below:

var paramsForFilteredResult = {

    inclusive: true,

    fieldName: "ResultID",

    t:MyInfotableResult,

    pattern: "Result1"

};

var FilteredByResult = Resources["InfoTableFunctions"].LikeFilter(paramsForFilteredResult);

But I am wondering, is it possible using this function to search for multiple patterns? For example, what if I want to show Result1 and Result2, not just Result1? I have tried incorporating forloops and a number of different syntax approaches, but I don't seem to be having luck.

Any help is greatly appreciated!

- Jon

Best answer by CarlesColl

Hi Jon,

I did exactly a few hours ago a query to an Infotable, that's the exact code ( like it's the query string text 😞

if (like) {

    result = Resources["InfoTableFunctions"].Query({

        t: result,

        query:  {

            "filters": {

                "fieldName": "name",

                "type": "LIKE",

                "value": ("*"+like+"*")

            }

        }

    });

}

4 replies

22-Sapphire I
August 25, 2016

Usually for more complex filters I use Query

and this reference in the javadoc

Query Parameter for Query Services

jweiss1-VisitorAuthor
1-Visitor
August 25, 2016

Thanks, Pai. I'll check it out.

1-Visitor
August 26, 2016

Hi Jon,

I use LIKE that way and it works:

{ "fieldName": "queryFieldName", "type": "LIKE", "value": ("*"+likeText+"*") }

1-Visitor
August 26, 2016

Hi  Jon, You can use most of the regular expression that a java script supports, like Carles mentioned you can use '*' to filter data. Also day if you want to filter data while has 'Result' as prefix followed by a number then you can use "Result\\d", in this case you will get Result1, Resut2 but not Results ot Results1.

Another exaple is, if you want to filter all records with values a or b or c then you can use "[abc]"

Hope this helps,

Regards,

Siva

jweiss1-VisitorAuthor
1-Visitor
August 26, 2016

Thanks for the followup, everyone.

I am working to implement what Charles mentioned, but am having some server issues at the moment. Will get it up and tested as soon as I can. Charles, I am trying to query an infotable.

1-Visitor
August 26, 2016

Hi Jon,

I did exactly a few hours ago a query to an Infotable, that's the exact code ( like it's the query string text 😞

if (like) {

    result = Resources["InfoTableFunctions"].Query({

        t: result,

        query:  {

            "filters": {

                "fieldName": "name",

                "type": "LIKE",

                "value": ("*"+like+"*")

            }

        }

    });

}

jweiss1-VisitorAuthor
1-Visitor
August 26, 2016

Awesome. Thanks for sharing! I will test it out as soon as I can.