above is the result of expression rule i want to remove mail and make value like test@gmail.com as key and numbers that are after : as value
and leave period as is
Discussion posts and replies are publicly visible
a!update()
a!localVariables( local!returnedDataFromRule: { a!map( mail: { "test1@gamil.com:1", "test2@gamil.com:2", "test3@gamil.com:3" }, period: "01/2024" ), a!map( mail: { "test@gamil.com:4", }, period: "01/2024" ) }, local!keysAndValues: a!forEach( items: a!flatten( property(local!returnedDataFromRule, "mail", "") ), expression: a!map( key: split(fv!item, ":")[1], value: split(fv!item, ":")[2] ) ), a!update( data: a!map(), index: { property(local!keysAndValues, "key", "") }, value: { property(local!keysAndValues, "value", ""), } ), )
Hi Eren,
Thanks for the reply, I need Period value Aswell along with emails
for example,
Thanks in Advance.
Hi Mufeeda,In your example data i can see multiple periods ,but in output you want only one ? if yes then what is the period id that you want ? if no then as I mentioned above we can not have duplicate keys.below is the code for getting all the unique period valus
a!localVariables( local!returnedDataFromRule: { a!map( mail: { "test1@gamil.com:1", "test2@gamil.com:2", "test3@gamil.com:3" }, period: "01/2024" ), a!map( mail: { "test@gamil.com:4"}, period: "01/2024" ) }, local!keysAndValues: a!forEach( items: a!flatten( property(local!returnedDataFromRule, "mail", "") ), expression: a!map( key: split(fv!item, ":")[1], value: split(fv!item, ":")[2] ) ), local!periods: a!flatten( property(local!returnedDataFromRule, "period", "") ), local!emails: a!update( data: a!map(), index: { property(local!keysAndValues, "key", ""), }, value: { property(local!keysAndValues, "value", ""), } ), a!update( data: local!emails, index: "period", value: union(local!periods,local!periods) ) )