Inconsistent data types (Text vs Variant) in List of Map output

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

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Try this: 

    a!localVariables(
    local!indexval: index(ri!userFilters, "userFilter", null),
    local!filters: split(local!indexval, ";"),

    /* Find the segment containing AccountName */
    local!accountSegment: a!forEach(
    items: local!filters,
    expression: if(find("name=AccountName", fv!item) > 0, fv!item, null)
    ),
    local!accountRaw: index(
    filter(not(isnull(fv!item)), local!accountSegment),
    1, null
    ),

    /* Find the segment containing Product Category */
    local!productSegment: a!forEach(
    items: local!filters,
    expression: if(find("name=Product Category", fv!item) > 0, fv!item, null)
    ),
    local!productRaw: index(
    filter(not(isnull(fv!item)), local!productSegment),
    1, null
    ),

    /* Parse AccountName values */
    local!accountValues: if(
    isnull(local!accountRaw),
    {},
    a!localVariables(
    local!start: find("value=[", local!accountRaw),
    local!block: mid(
    local!accountRaw,
    local!start + 7,
    len(local!accountRaw)
    ),
    local!clean: substitute(
    substitute(local!block, "]", ""),
    "isArray=true,", ""
    ),
    filter(
    not(isnull(fv!item)) && fv!item <> "",
    a!forEach(
    items: split(local!clean, ","),
    expression: trim(substitute(fv!item, """", ""))
    )
    )
    )
    ),

    /* Parse ProductCategory values */
    local!productValues: if(
    isnull(local!productRaw),
    {},
    a!localVariables(
    local!start: find("value=[", local!productRaw),
    local!block: mid(
    local!productRaw,
    local!start + 7,
    len(local!productRaw)
    ),
    local!clean: substitute(
    substitute(local!block, "]", ""),
    "isArray=true,", ""
    ),
    filter(
    not(isnull(fv!item)) && fv!item <> "",
    a!forEach(
    items: split(local!clean, ","),
    expression: trim(substitute(fv!item, """", ""))
    )
    )
    )
    ),

    /* Single combined map */
    a!map(
    AccountName: local!accountValues,
    ProductCategory: local!productValues
    )
    )

    Issue
    Two separate maps
    isArray=true
    Empty strings in output

Reply
  • 0
    Certified Lead Developer

    Try this: 

    a!localVariables(
    local!indexval: index(ri!userFilters, "userFilter", null),
    local!filters: split(local!indexval, ";"),

    /* Find the segment containing AccountName */
    local!accountSegment: a!forEach(
    items: local!filters,
    expression: if(find("name=AccountName", fv!item) > 0, fv!item, null)
    ),
    local!accountRaw: index(
    filter(not(isnull(fv!item)), local!accountSegment),
    1, null
    ),

    /* Find the segment containing Product Category */
    local!productSegment: a!forEach(
    items: local!filters,
    expression: if(find("name=Product Category", fv!item) > 0, fv!item, null)
    ),
    local!productRaw: index(
    filter(not(isnull(fv!item)), local!productSegment),
    1, null
    ),

    /* Parse AccountName values */
    local!accountValues: if(
    isnull(local!accountRaw),
    {},
    a!localVariables(
    local!start: find("value=[", local!accountRaw),
    local!block: mid(
    local!accountRaw,
    local!start + 7,
    len(local!accountRaw)
    ),
    local!clean: substitute(
    substitute(local!block, "]", ""),
    "isArray=true,", ""
    ),
    filter(
    not(isnull(fv!item)) && fv!item <> "",
    a!forEach(
    items: split(local!clean, ","),
    expression: trim(substitute(fv!item, """", ""))
    )
    )
    )
    ),

    /* Parse ProductCategory values */
    local!productValues: if(
    isnull(local!productRaw),
    {},
    a!localVariables(
    local!start: find("value=[", local!productRaw),
    local!block: mid(
    local!productRaw,
    local!start + 7,
    len(local!productRaw)
    ),
    local!clean: substitute(
    substitute(local!block, "]", ""),
    "isArray=true,", ""
    ),
    filter(
    not(isnull(fv!item)) && fv!item <> "",
    a!forEach(
    items: split(local!clean, ","),
    expression: trim(substitute(fv!item, """", ""))
    )
    )
    )
    ),

    /* Single combined map */
    a!map(
    AccountName: local!accountValues,
    ProductCategory: local!productValues
    )
    )

    Issue
    Two separate maps
    isArray=true
    Empty strings in output

Children
No Data