Skip to main content
June 13, 2021
Question

Cannot apply operator [EQUALS] to field [policyStatus] when comparing to value [TypedValue[it=126,v={1}]].

  • June 13, 2021
  • 12 replies
  • 1 view

/* I am trying to extract cancelled status but having error.
Can you please help me. Thank you*/

a!queryEntity(
  fetchTotalCount: true,
  entity: cons!CAS_DSE_VIEW_POLICY_RECORD,
  query: a!query(
    pagingInfo: if(
      rule!GBL_isBlank(ri!pagingInfo),
      a!pagingInfo(
        startIndex: 1,
        batchSize: 5
      ),
      ri!pagingInfo
    ),
    logicalExpression: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        if(
          rule!GBL_isBlank(ri!policySearch.policyId),
          {},
          a!queryFilter(
            field: "policyId",
            value: ri!policySearch.policyId,
            operator: "="
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.currency),
          {},
          a!queryFilter(
            field: "projectCurrency",
            value: ri!policySearch.currency,
            operator: "="
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.carrierPolicyId),
          {},
          a!queryFilter(
            field: "carrierPolicyId",
            value: ri!policySearch.carrierPolicyId,
            operator: "includes"
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.carrierName),
          {},
          a!queryFilter(
            field: "carrierName",
            value: ri!policySearch.carrierName,
            operator: "includes"
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.coverageCode),
          {},
          a!queryFilter(
            field: "coverageCode",
            value: ri!policySearch.coverageCode,
            operator: "="
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.aonCustomerId),
          {},
          a!queryFilter(
            field: "aonCustomerId",
            value: ri!policySearch.aonCustomerId,
            operator: "starts with"
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.customerName),
          {},
          a!queryFilter(
            field: "customerName",
            value: ri!policySearch.customerName,
            operator: "includes"
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.aonProjectId),
          {},
          a!queryFilter(
            field: "aonProjectId",
            value: ri!policySearch.aonProjectId,
            operator: "starts with"
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.policyStatus),
          {},
          a!queryFilter(
            field: "policyStatus",
            operator: "in",
            value: ri!policySearch.policyStatus
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.practice),
          {},
          a!queryFilter(
            field: "practice",
            value: ri!policySearch.practice,
            operator: "in"
          )
        ),
        if(
          rule!GBL_isBlank(ri!policySearch.cancelledPolicies),
          {},
          a!queryFilter(
            field: "policyStatus",
            operator: "=",             
                  applyWhen: ri!policySearch.cancelledPolicies = true,
                  value: if((ri!policySearch.cancelledPolicies = true),
                  (ri!policySearch.policyStatus <> cons!CAS_REFERENCE_DATA_ID_POLICY_STATUS_CANCELLED),
                  ri!policySearch.policyStatus)
                )
            ),
      }
    )
  )
)

I am trying to extract cancelled status but having error.
Can you please help me. Thank you

    12 replies

    stefanhelzle0001
    Brainy
    June 13, 2021

    OMG, all the ifs ... why? applyWhen or ignoreEmptyFilters should do most of the job.

    You have two different filters on policyStatus. One in line 112 and one in 94. The one on 94 works, so I assume that your rule input is multiple. That does not work in 112 with the "=".

    June 14, 2021

    Hi Stefan, 

    Correct, the one on 94 works and the one in 112 is encountering and error. We have two filters (1) for policy status which is a dropdown choice vaues; (2) option to exclude the canceled policy status which is a checkbox, if no specific status was chosen in the first one and wanted to show all except canceled

    stefanhelzle0001
    Brainy
    June 14, 2021

    Yeah... then you need to turn the list with a single item into just that item. One option is to use the index() function to fetch the first item.