/* 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
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 "=".
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
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.
a!queryFilter( field: "policyStatus", operator: "<>", applyWhen: ri!policySearch.cancelledPolicies = true, value: index(ri!policySearch.policyStatus,"policyStatus", cons!CAS_REFERENCE_DATA_ID_POLICY_STATUS_CANCELLED) )
I mean something like
index(ri!policySearch.policyStatus, 1, cons!CAS_REFERENCE_DATA_ID_POLICY_STATUS_CANCELLED)
This tries to fetch the first item and in case the list is empty, it returns the constant.
Give it a try. If Appian complains about the data type, add a tostring().
still encountering Cannot apply operator [NOT EQUAL] to field [policyStatus] when comparing to value [TypedValue[it=3,v=9]] after trying tostring(index(ri!policySearch.policyStatus, 1, cons!CAS_REFERENCE_DATA_ID_POLICY_STATUS_CANCELLED)) as well
Could it be that policyStatus is an integer? Then tointeger() will work better than tostring().
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")) ) ),
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.
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")) ) ),
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")) ) ),
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.