Hi All, I have created a query Entity that fetches data from a view.

Hi All,

I have created a query Entity that fetches data from a view. I am facing issue when the query entity has blank inputs & it tries to fetch all the values. How can I make sure to return no values when the input is null. Below s the query entity code:

= a!queryEntity(
entity: cons!LISTING,
query: a!query(
logicalExpression: if(
and(
rule!APN_isBlank(
ri!Num
),
rule!APN_isBlank(
ri!secondID
),
rule!APN_isBlank(
ri!Code
),
rule!APN_isBlank(
ri!D
)
),
null,
a!queryLogicalExpression(
operator: "AND",
filters: {
if(
rule!APN_isBlank(
ri!Num
),
{},
a!queryFilter(
field: "Num",
operator: "=",
value: ri!Num
)
),
if(
rule!APN_isBlank(...

OriginalPostID-208504

OriginalPostID-208504

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    you can put if condition before applying filter

    just like
    a!queryEntity(
    entity: cons!COB_DATASTORE_CUSTOMER_CASE,
    query: a!query(
    selection: if(
    rule!COB_verifyIsNullorEmpty(
    ri!selectionColumns
    ),
    {},
    a!querySelection(
    columns: apply(
    rule!COB_dynamicQueryColumn,
    {
    ri!selectionColumns
    }
    )
    )
    ),
    pagingInfo: if(
    isnull(
    ri!pagingInfo
    ),
    a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    ),
    ri!pagingInfo
    ),
    logicalExpression: if(
    and(
    rule!COB_verifyIsNullorEmpty(
    ri!Id
    ),
    rule!COB_verifyIsNullorEmpty(
    ri!Name
    ),
    rule!COB_verifyIsNullorEmpty(
    ri!customerId
    ),
    rule!COB_verifyIsNullorEmpty(
    ri!caseStatus
    )
    ),
    null,
    a!queryLogicalExpression(
    operator: "AND",
    filters: {
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!Id
    ),
    {},
    a!queryFilter(
    field: "Id",
    operator: "=",
    value: ri!Id
    )
    ),
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!Name
    ),
    {},
    a!queryFilter(
    field: "Name",
    operator: "includes",
    value: ri!Name
    )
    ),
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!customerId
    ),
    {},
    a!queryFilter(
    field: "CustomerId",
    operator: "=",
    value: ri!customerId
    )
    ),
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!caseStatus
    ),
    {},
    a!queryFilter(
    field: "CaseStatus",
    operator: "=",
    value: ri!caseStatus
    )
    )
    }
    )
    )
    )
    ).data
Reply
  • 0
    Certified Senior Developer
    you can put if condition before applying filter

    just like
    a!queryEntity(
    entity: cons!COB_DATASTORE_CUSTOMER_CASE,
    query: a!query(
    selection: if(
    rule!COB_verifyIsNullorEmpty(
    ri!selectionColumns
    ),
    {},
    a!querySelection(
    columns: apply(
    rule!COB_dynamicQueryColumn,
    {
    ri!selectionColumns
    }
    )
    )
    ),
    pagingInfo: if(
    isnull(
    ri!pagingInfo
    ),
    a!pagingInfo(
    startIndex: 1,
    batchSize: - 1
    ),
    ri!pagingInfo
    ),
    logicalExpression: if(
    and(
    rule!COB_verifyIsNullorEmpty(
    ri!Id
    ),
    rule!COB_verifyIsNullorEmpty(
    ri!Name
    ),
    rule!COB_verifyIsNullorEmpty(
    ri!customerId
    ),
    rule!COB_verifyIsNullorEmpty(
    ri!caseStatus
    )
    ),
    null,
    a!queryLogicalExpression(
    operator: "AND",
    filters: {
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!Id
    ),
    {},
    a!queryFilter(
    field: "Id",
    operator: "=",
    value: ri!Id
    )
    ),
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!Name
    ),
    {},
    a!queryFilter(
    field: "Name",
    operator: "includes",
    value: ri!Name
    )
    ),
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!customerId
    ),
    {},
    a!queryFilter(
    field: "CustomerId",
    operator: "=",
    value: ri!customerId
    )
    ),
    if(
    rule!COB_verifyIsNullorEmpty(
    ri!caseStatus
    ),
    {},
    a!queryFilter(
    field: "CaseStatus",
    operator: "=",
    value: ri!caseStatus
    )
    )
    }
    )
    )
    )
    ).data
Children
No Data