Skip to main content
May 22, 2025
Question

Map index delete

  • May 22, 2025
  • 7 replies
  • 0 views

Hello All,

I am facing issue with the following map. I am building dynamic filters. Here is the map is the output. But I wanted to delete logicalExpression:{} from the map. It can be there at any level. If logicalExpression is null then my resulted map should not contain logicalExpression:{}

a!localVariables(
  local!conditions: {
    a!map(
      operator: "AND",
      logicalExpressions: {
        a!map(
          operator: "AND",
          filters: {
            a!map(field: null, operator: null, value: null),
            a!map(field: null, operator: null, value: null)
          },
          logicalExpressions: {
            a!map(
              operator: "AND",
              filters: {
                a!map(field: null, operator: null, value: null),
                a!map(field: null, operator: null, value: null)
              },
              logicalExpressions: {}
            ),
            a!map(
              operator: "AND",
              filters: {
                a!map(field: null, operator: null, value: null),
                a!map(field: null, operator: null, value: null)
              },
              logicalExpressions: {}
            )
          }
        )
      }
    )
  },
local!conditions
)

7 replies

amaans4178
May 22, 2025

As far as I understand, this may require a recursive approach, given that the structure is hierarchical and can have multiple levels.
Please feel free to correct me if I’m mistaken.

rupaa0642Author
May 22, 2025

Yes you are correct

davidj137213
May 22, 2025

You ned to use a recursive approach... or try converting the array to json... replace the elements with a regular expression, and convert it again to an appian structure..

rupaa0642Author
May 22, 2025

Can you pls give me an example for JSON approach

davidj137213
May 22, 2025

it would be something like....

a!fromjson(substitute(a!tosjon(local!conditions), "logicalExpressions"":[]", null))

But you have to be care of closing tags, and keep the json structure

mikes0011
Brainy
May 22, 2025

It's a little ambiguous what you're after, without some examples of different inputs and what you would expect the outputs to be (and why). 

Generally, you can't exactly "delete" something from a map, but similarly to the JSON approach, you could always structure an expression to build a new map from an existing map and just omit certain properties when needed.