Hi All I am trying to design a generic rule which will take recordtype. filter fields and filter values and filter operators and final filed as inputs and it should give result of that final field after ruining the query Record and applying the aggregation.It is working if the filter are single or multiple and all filter operators are "=","<>","<",">" but not when filters are multiple and operators are mix of in ,= or not in,= .here is the code i have used.
a!localVariables( local!filterFields: { recordFields }, local!filterValues: { a!update(a!map(), "1", { 21, 27 }), true() }, local!filterOperators: { "in", "=" }, index( a!queryRecordType( recordType: recordName, fields: finalOutputField, filters: a!queryLogicalExpression( operator: "AND", filters: a!forEach( items: { local!filterFields }, expression: a!queryFilter( field: fv!item, operator: local!filterOperators[fv!index], value: if( contains( { "in", "not in" }, local!filterOperators[fv!index][1] ), a!localVariables( local!indexData: local!filterValues[fv!index][1], if( a!isNullOrEmpty(local!indexData), local!filterValues[touniformstring(fv!index)][1], local!indexData ) ), local!filterValues[fv!index] ) ) ), ignoreFiltersWithEmptyValues: true ), fetchTotalCount: true(), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 0) ), "totalCount", {} ) )
Discussion posts and replies are publicly visible
Thanks All,Found the issue and able to fix it.
index( a!queryRecordType( recordType: ri!record, fields: ri!finalField, filters: a!queryLogicalExpression( operator: "AND", filters: if( a!isNullOrEmpty(ri!filterFields), {}, a!forEach( items: ri!filterFields, expression: a!queryFilter( field: fv!item, operator: ri!filterOperators[fv!index], value: if( contains( { "in", "not in" }, ri!filterOperators[fv!index] ), a!localVariables( local!indexData: index(ri!filterValues[fv!index], fv!index, {}), if( a!isNullOrEmpty(local!indexData), index( ri!filterValues[fv!index], touniformstring(fv!index), {} ), local!indexData ) ), index( ri!filterValues[fv!index], touniformstring(fv!index), {} ) ), ) ) ), ignoreFiltersWithEmptyValues: true ), fetchTotalCount: true(), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 0) ), "totalCount", {} )