In need to group a column and get count of other column data on output of a query, getting below error

In need to group a column and get count of other column data on output of a query, getting below error:
Expression evaluation error in rule 'bwis_wf_rep_displayrequestcolumnchart' (called by rule 'bwis_wf_rep_displaymanagerialreport') at function a!queryEntity [line 40]: Cannot apply operator [IN] to field [requestId] when comparing to value [TypedValue[it=197,v={}]] for the code i have added.
Please find attached query code.
Thanks,
Madhu

OriginalPostID-174778

 

complete code.txt

  Discussion posts and replies are publicly visible

  • @madhubindug Not sure how much this will help you, but as per your code snippet there seems to be a problem with the way you are accessing the 'requestId' attribute in the query filter.

    I guess you it would be worth correcting the value of the queryFilter as shown below and then start debugging.

    In your code snippet:
    value: local!datasubsetDeficiency.data.requesId

    What you should do is:
    value: local!datasubsetDeficiency.data.requestId
  • It seems the value is null "v={}"
    Check local!datasubsetDeficiency.data.requesId is not null. You could use local!datasubsetDeficiency.totalcount = 0
  • Thanks for the correction @#sikhivhans, now am getting below error
    Expression evaluation error in rule 'bwis_wf_rep_displayrequestcolumnchart' (called by rule 'bwis_wf_rep_displaymanagerialreport') at function a!queryEntity [line 99]: Cannot apply operator [IN] to field [requestId] when comparing to value [TypedValue[it=3,v=52404; 52631; 52769; 53395; 53395; 54145; 54617; 55449; 55628; 55628; 55683; 55735; 56005; 56033; 56144; 56144; 56323; 56350; 56350; 268488564; 268488590; 268489011; 268489296; 268489296; 268490148; 268491783; 268491943; 268491990; 268491990; 536927028; 536927094; 536927197; 536927236; 536927236; 536927306; 536927396; 536927396; 536927396; 536927533; 536927633; 536927785; 536928107; 536929618; 536929673; 536929910; 536930052; 536930204; 536930444]].

    Is it like i cannot apply operator IN for this?

    Thanks,
    Madhu
  • @madhubindhu No worries. Can you please give an attempt with the following snippet and let me know the output?

    a!queryFilter(
    field: "requestId",
    operator: "in",
    value: tointeger(local!datasubsetDeficiency.data.requestId)
    )
  • @madhubindug Not sure if the above solution has helped you or not, just now I have faced the same issue and resolved the value by converting the values to a plain array using tointeger(). The actual problem here is, the data returned by a!queryEntity() which is in the format of datasubset of dictionaries returns you an array of arrays when you try to access the fields inside the data. (for instance, local!datasubsetDeficiency.data.requestId in your case.) As IN operator expects a plain array, the queryFilter fails and hence the expression fails on the whole. So we should type cast the value of the queryFilter, i.e. we should convert the value into a plain array using functions such as tointeger() and thereafter we should provide the same to the queryFilter.
  • Hi @sikhivahans, below code worked for me, without tointeger() or tostring(),
    a!queryFilter(
    field: "requestId",
    operator: "in",
    value: {
    split(
    local!datasubsetDeficiency.data.requestId,
    ";"
    )
    }
    )
    @Neelima J : thanks
  • @madhubindug Hmm Great..! The idea behind the split is also same. The array of arrays are flattened finally, as the split() returns a plain array. At times the usage of split might not be ideal in case if the text values contain semi colons between them.