Query entity with multiple logical expressions

A Score Level 2

Is it possible to have a query entity with multiple logical expressions? i.e. have a query entity that has a logical expression that 'AND's a set of filters and another logical expression that 'OR's a set of filters and 'AND's those two logical expressions together. Any info is greatly appreciated

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi,

    It is possible. In this case, it should satisfy both logical expressions. All filters should be true in AND logical expression and any one of the filters should be true in OR logical expression.

    Please have a look in the code:

    a!queryEntity(
    entity: cons!PG_ENTITY_EMPLOYEE_DETAILS,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    logicalExpressions: {
    a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    field: "RequestId",
    operator: "=",
    value: ri!requestId
    )
    }
    ),
    a!queryLogicalExpression(
    operator: "OR",
    filters: {
    a!queryFilter(
    field: "Status",
    operator: "=",
    value: ri!status
    ),
    a!queryFilter(
    field: "IsActive",
    operator: "=",
    value: ri!isActive
    )
    }
    )
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    )
    )
    )

Reply
  • 0
    Certified Lead Developer

    Hi,

    It is possible. In this case, it should satisfy both logical expressions. All filters should be true in AND logical expression and any one of the filters should be true in OR logical expression.

    Please have a look in the code:

    a!queryEntity(
    entity: cons!PG_ENTITY_EMPLOYEE_DETAILS,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    logicalExpressions: {
    a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    field: "RequestId",
    operator: "=",
    value: ri!requestId
    )
    }
    ),
    a!queryLogicalExpression(
    operator: "OR",
    filters: {
    a!queryFilter(
    field: "Status",
    operator: "=",
    value: ri!status
    ),
    a!queryFilter(
    field: "IsActive",
    operator: "=",
    value: ri!isActive
    )
    }
    )
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    )
    )
    )

Children
No Data