I am working with a rule in Appian where I expect a consistent structure of List of Map, but I am seeing inconsistent data types in the output.a!localVariables( local!indexval: index( ri!userFilters, "userFilter", null ), local!filters: split(local!indexval, ";"), a!forEach( items: local!filters, expression: a!localVariables( local!valueStart: find("value=[", fv!item), local!valueBlock: if( isnull(local!valueStart), "", mid( fv!item, local!valueStart + 7, len(fv!item) ) ), local!cleanValueBlock: substitute(local!valueBlock, "]", ""), /*Values */ local!AccountName: if( find("name=AccountName", fv!item) > 0, a!forEach( items: split(local!cleanValueBlock, ","), expression: trim(substitute(fv!item, """", "")) ), {} ), local!ProductCategory: if( find("name=Product Category", fv!item) > 0, a!forEach( items: split(local!cleanValueBlock, ","), expression: trim(substitute(fv!item, """", "")) ), {} ), a!map( AccountName: local!AccountName, ProductCategory: local!ProductCategory ) ) ))expecting ProductCategory and Account name in single map
List of Map
Discussion posts and replies are publicly visible
Your if() returns empty List of Variant when the condition fails, and a!forEach makes one map per filter (not merged).Type the empty fallback and merge after the loop.See below - Returns one map with both keys as List of Text.
a!localVariables( local!filters: split(index(ri!userFilters, "userFilter", null), ";"), local!parsed: a!forEach( items: local!filters, expression: a!localVariables( local!vStart: find("value=[", fv!item), local!vBlock: if(isnull(local!vStart), "", mid(fv!item, local!vStart + 7, len(fv!item))), local!values: a!forEach( items: split(substitute(local!vBlock, "]", ""), ","), expression: trim(substitute(fv!item, """", "")) ), a!map( type: if(find("name=AccountName", fv!item) > 0, "A", "P"), values: local!values ) ) ), a!map( AccountName: index(local!parsed, wherecontains("A", local!parsed.type), a!map()).values, ProductCategory: index(local!parsed, wherecontains("P", local!parsed.type), a!map()).values ) )