Dictionary comparison not returning correct output

Certified Lead Developer

I am facing a weird issue when comparing two arrays of dictionary type. As in the code attached, I have two arrays of dictionary from which I am converting one of them to be similar to other one using foreach loop. I am pretty much sure that output after conversion is same as "array1" in code snippet.

But, still their comparison returns {false, false, false} as output of it. And, when I run the commented comparison below, it returns {true, true, true}.

Why direct comparison is returning correct output but not the output from foreach besides the fact that formats and outputs are exactly same.

a!localVariables(
  local!array1: {
    { value1: "abc", value2: "cde" },
    { value1: "fty", value2: "yui" },
    { value1: "uiu", value2: "dft" }
  },
  local!array2: {
    { value1: "abc", value2: "cde", value3: "gdh" },
    { value1: "fty", value2: "yui", value3: "hyu" },
    { value1: "uiu", value2: "dft", value3: "kol" }
  },
  local!convertedArray2: a!forEach(
    items: local!array2,
    expression: {
      value1: fv!item.value1,
      value2: fv!item.value2
    }
  ),
  local!convertedArray2 = local!array1
  /*local!array1 = local!array1*/
)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    I am not really surprised. Dictionaries have some edge cases. This is why Appian recommends to use maps instead.

    https://docs.appian.com/suite/help/23.4/parts-of-an-expression.html#dictionaries

    Your code works great when using maps.

    a!localVariables(
      local!array1: {
        a!map( value1: "abc", value2: "cde" ),
        a!map( value1: "fty", value2: "yui" ),
        a!map( value1: "uiu", value2: "dft" )
      },
      local!array2: {
        a!map( value1: "abc", value2: "cde", value3: "gdh" ),
        a!map( value1: "fty", value2: "yui", value3: "hyu" ),
        a!map( value1: "uiu", value2: "dft", value3: "kol" )
      },
      local!convertedArray2: a!forEach(
        items: local!array2,
        expression: a!map(
          value1: fv!item.value1,
          value2: fv!item.value2
        )
      ),
      local!convertedArray2 = local!array1
      /*local!array1 = local!array1*/
    )
    

Reply
  • +1
    Certified Lead Developer

    I am not really surprised. Dictionaries have some edge cases. This is why Appian recommends to use maps instead.

    https://docs.appian.com/suite/help/23.4/parts-of-an-expression.html#dictionaries

    Your code works great when using maps.

    a!localVariables(
      local!array1: {
        a!map( value1: "abc", value2: "cde" ),
        a!map( value1: "fty", value2: "yui" ),
        a!map( value1: "uiu", value2: "dft" )
      },
      local!array2: {
        a!map( value1: "abc", value2: "cde", value3: "gdh" ),
        a!map( value1: "fty", value2: "yui", value3: "hyu" ),
        a!map( value1: "uiu", value2: "dft", value3: "kol" )
      },
      local!convertedArray2: a!forEach(
        items: local!array2,
        expression: a!map(
          value1: fv!item.value1,
          value2: fv!item.value2
        )
      ),
      local!convertedArray2 = local!array1
      /*local!array1 = local!array1*/
    )
    

Children