Is there a way to *dynamically* add a new element to a dictionary?

I'd like to at run time add new name value pair to a dictionary. Is this possible?

Thanks.

OriginalPostID-239395

  Discussion posts and replies are publicly visible

Parents Reply
  • Stefan, I've executed Shashanks code and it works great. Thank you for your contributions.

    How would you incorporate this approach within a foreach() where items is a list of dictionary and local!test output contains custom key:value pairs derived from each dictionary in the list?

    Ex: local!dictionaries: {{ id:1, name:"alpha" },{ id:2, name:"bravo" }.{ id:3, name:"charlie" }}

    local!test output: { alpha:1, bravo:2, charlie:3 }

    with(
      local!test: {
        {
          id: 1,
          name: "test"
        }
      },
      local!newKeyValPair: a!fromJson(
        substitute(
          a!toJson(
            {
              tzqYx62_01_: ri!value
            }
          ),
          "tzqYx62_01_",
          ri!key
        )
      ),
      local!updated: updatecdt(
        local!test,
        local!newKeyValPair
      ),
      local!updated
    )

Children