Chaining filters in the API

Hello everyone,

while using the standard API you can often input filters. Sadly I have only be able to use one filter per request. 

E. g.: {{baseUrl}}/portal/person/all?PageSize=50&filter=[{"CompareOp":0,"Type":0,"ColumnName":"IsInActive","Value1":"0"}]AND[{"CompareOp":0,"Type":0,"ColumnName":"IsInActive","Value1":"0"}]

Is it possible to use multiple filters in one call. If yes, how is the syntax? Can you chain them with AND or OR?

Thanks in advance

Parents
  • Hi, Lennart, 

    In my case it's been hard to find out. You can build an array of expressions if the filter type is of type Expression.

    I've been using this in my code to filter gapaccounts by domains. Something like:

    const myexpressions=[];
    this.myfilter = [{
            Type:FilterType.Expression,
            Expression: {
               LogOperator:LogOp.OR,
               Expressions: myexpressions
               
            }
          },
          ];
    myexpressions.push(
              { LogOperator:LogOp.AND,
                Operator:'LIKE',
                PropertyId: 'PrimaryEmail',
                Value: "@eprinsa.es"
              }
            )
    myexpressions.push(
              { LogOperator:LogOp.AND,
                Operator:'LIKE',
                PropertyId: 'PrimaryEmail',
                Value: "@dipucordoba.es "
              }
            )

    this.navigationState.filter = this.myfilter;

    Hth!

  • Hi juancarlos,

    thanks for the response. Unfortunately I need a solution which I can use just in the param of the API Call with postman, without writing code.

    So like {{baseUrl}}/portal/person/all?PageSize=50&filter=[{"CompareOp":0,"Type":0,"ColumnName":"IsInActive","Value1":"0"}]

    but with multiple filters.

  • Afraid I'm not using postman, ony thing I can do is translate the constant names into values. Try to build the json body with them.

    Type = (FilterType.Expression )= 2

    export declare enum LogOp {
        AND = 0,
        OR = 1,
        Undefined = 2
    }
  • Sweat smile took a bit but here. 

    https://<url>/Apiserver/portal/targetsystem/GAPUser

    ?filter=[{"Type":2,"Expression":{"LogOperator":0,"Expressions":[{"LogOperator":"1","Operator":"LIKE","PropertyId":"PrimaryEmail","Value":"@eprinsa.es"}]}}]

    will show all gapaccounts under the domain @eprinsa.es 

    You can modify and extend more expressions to the array "Expressions"

Reply
  • Sweat smile took a bit but here. 

    https://<url>/Apiserver/portal/targetsystem/GAPUser

    ?filter=[{"Type":2,"Expression":{"LogOperator":0,"Expressions":[{"LogOperator":"1","Operator":"LIKE","PropertyId":"PrimaryEmail","Value":"@eprinsa.es"}]}}]

    will show all gapaccounts under the domain @eprinsa.es 

    You can modify and extend more expressions to the array "Expressions"

Children
No Data