I have this code which I use to query task report. I want the filter to check if the asignee groups are in an array of input groups. Take a look at the working example first:
a!queryProcessAnalytics( report: cons!GBD_Report, contextProcessModels: cons!GBD_Process, query: a!query( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 100, sort: a!sortInfo( field: "c2", ascending: true ), ), filter: a!queryFilter( field: "c4", operator: "=", value: ri!group ) ), ),
This works because ri!group is not an array but a single group. However when I turn the ri!group into an array of groups, and instead of operator "=" use operator "in" so basically check if group is IN an array of groups I get no data. If I use "not in" operator I get the opposite - I get all tasks. What is the issue here?
Discussion posts and replies are publicly visible
Do it this way
a!forEach(items: ri!group, expression: a!queryFilter( field: "c4", operator: "=", value: fv!item, applyWhen: a!isNotNullOrEmpty(reject(fn!isnull, ri!group)) ), )
But this applies all filters at once right? This means the resulting tasks will have to be in the both groups? I want to return tasks that match any group. So like an union.Also when I test this it only works for the first group in the array.When I put only group A as input I get 14 tasks.When I put group B as input I get 4 tasks.When I put {A, B} I get 14 tasks.When I put {B, A} I get 4 tasks.
What is going on here?
Use or operator instead of AND (more than one queryLogicalExpression can be used in logicalExpressions)
a!queryLogicalExpression( operator: "OR", filters: { a!forEach(items: ri!group, expression: a!queryFilter( field: "c4", operator: "=", value: fv!item, applyWhen: a!isNotNullOrEmpty(reject(fn!isnull, ri!group)) ), )}),
Thanks this solves it.
One more thing, why doesn't "in" operator work in this case?
your value needs to be passed in the array format.
It was. I checked in my test inputs it said array of groups.
hopefully your rule input is configured as an array and not receiving any nulls in the given array of values.
Ofcourse. Configured as an array and I have tested that the constants that pointed to the groups I am using were working individually.
Like this.
I am not sure why. I haven't tried this before. Have you checked what would contextGroups parameter of a!queryProcessAnalytics() do in this?