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

/* 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

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi Stefan, 

    Tostring works well and we're able to exclude canceled status when checkbox is ticked, thank you very much for your help. However, when checkbox and dropdown for policy status both have value, we don't fetch any details at all, e.g., we have OPEN status selected for dropdown and the checkbox is ticked. Do you have any idea why this happened?  

    if(
              rule!GBL_isBlank(ri!policySearch.policyStatus),
              {},
              a!queryFilter(
                field: "policyStatus",
                operator: "in",
                value: ri!policySearch.policyStatus
              )
            ),
    if(
              rule!GBL_isBlank(ri!policySearch.cancelledPolicies),
              {},
              a!queryFilter(
                field: "policyStatus",
                operator: if (
                  ri!policySearch.cancelledPolicies = true,
                  "<>","in"),
                applyWhen: ri!policySearch.cancelledPolicies = true,
                value: tostring(index(ri!policySearch.policyStatus, 1, "Cancelled"))
                )
               ),

  • 0
    Certified Lead Developer
    in reply to memvergara

    Lines 10 ff is weird. You only use the filter if cancelledPolicies is NULL/empty string. Then in line 16 you check whether that value is true, and in 18 you disable the filter if the value is true.

    Sorry to say, but this does not feel correct ...

  • if(
              rule!GBL_isBlank(ri!policySearch.cancelledPolicies),
              {},
              a!queryFilter(
                field: "policyStatus",
                operator: "<>"
                applyWhen: ri!policySearch.cancelledPolicies = true,
                value: tostring(index(ri!policySearch.policyStatus, 1, "Cancelled"))
                )
               ),

    Sorry, this is the updated version of line 16. 

  • Hi Stefan, 

    We'd like to confirm if you got the chance to view the updated code?

            if(
              rule!GBL_isBlank(ri!policySearch.policyStatus),
              {},
              a!queryFilter(
                field: "policyStatus",
                operator: "in",
                value: ri!policySearch.policyStatus
              )
            ),
            if(
              rule!GBL_isBlank(ri!policySearch.cancelledPolicies),
              {},
              a!queryFilter(
                field: "policyStatus",
                operator: "<>"
                applyWhen: ri!policySearch.cancelledPolicies = true,
                value: tostring(index(ri!policySearch.policyStatus, 1, "Cancelled"))
                )
            ),

  • 0
    Certified Lead Developer
    in reply to memvergara

    Sorry, did not see your update. The issue here is that without knowing what the actual values of your rule inputs are it is impossible to say why things work or not.