OriginalPostID-239395
Discussion posts and replies are publicly visible
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 )
Update to the new versions of the Dictionary Manipulation plugin and use the code below
a!localVariables( local!values: {{ id:1, name:"alpha" },{ id:2, name:"bravo" },{ id:3, name:"charlie" }}, createdictionary( local!values.id, local!values.name ) )
Stefan, that would be wonderful, but I do not have the option to update to the new versions of the Dictionary Manipulation plugin. Is it possible to accomplish the same with your previous updatecdt / fromJson / toJson approach?
There was another post where a contributor suggested incorporating reduce() with your recipe for updatecdt() but I do not know how to work in the correct syntax to accomplish the desired outcome.
Why is an update no option? The new version includes to old functions as well.
This is a quick solution. I am pretty sure there is a better one.
a!localVariables( local!values: {{ id:1, name:"alpha" },{ id:2, name:"bravo" },{ id:3, name:"charlie" }}, reduce( updatecdt(_,_), cast(type!Dictionary, {}), a!forEach( items: local!values, expression: a!fromJson( substitute( a!toJson({tzqYx62_01_: fv!item.name}), "tzqYx62_01_", fv!item.id ) ) ) ) )
Wow Stefan, you never cease to amaze. Thank you for helping with this. As for the update, I am not an Administrator of our Appian systems. Things move slowly around here. Lots of red tape required but I will begin the process of requesting the update. For example: first qtr '20, upgraded from 18.2 to 19.4 (current). Grateful for 19.4. Thankful for your help, Sir.
You are welcome :-)