Hi,
I have below rule which gives output for distinct values only, but I want get output for indistinct values also.
For Ex: If I give rule input for groupId_int as {496,496,498} , I should get output for all 3 values though it repeats for 496 two times. But here I'm getting only for 2 items as below screen shot.
Can anyone please help me how to approach
index( a!queryEntity_22r2( entity: cons!RGRACSLBL_ENTITY_APPIAN_GROUPS, query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "Id_int", operator: "in", value: ri!groupId_int, applyWhen: not( rule!APN_isBlank( ri!groupId_int ) ) ), a!queryFilter( field: "groupName_txt", operator: "in", value: ri!groupName_txt, applyWhen: not( rule!APN_isBlank( ri!groupName_txt ) ) ) } ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: - 1 ) ) ), "data", {} )
Discussion posts and replies are publicly visible
use a!for each in query filter group_Id. so query will execute each iteration.
Doing a query in a foreach is a bad practice in terms of performance and memory consumption.
But, you could fetch the distinct items first, and then use a foreach on the incoming IDs to return the corresponding items.
It seems you are querying based on the result from ri!groupId_int(), and the database table will have only one record for 496 and hence it returned one resultset for 496.
As Stefan mentioned, query the distinct data on load and use the onload data to do the foreach on your group ids to get the data for your expected output. Don't do foreach on query itself which causes performance issues.