<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Merge Dictionaries</title><link>https://community.appian.com/discussions/f/rules/11391/merge-dictionaries</link><description>I have multiple dictionaries, each with a unique key, value pair. I would like to merge these dictionaries into a single dictionary. Any suggestions on how to accomplish this would be appreciated.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/72392?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 09:35:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a6e5612b-5bf3-453e-a0e7-2f92337bae85</guid><dc:creator>sweetyr1681</dc:creator><description>&lt;p&gt;You can use the Dictionary Utilities and use&amp;nbsp;&lt;span&gt;dictUtil_merge to merge the dictionaries.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/72385?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 10:58:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c1542008-d50e-40ee-a952-2f3c6e4b1d29</guid><dc:creator>GouthamKrishna</dc:creator><description>&lt;p&gt;Perfect !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/68761?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2019 15:12:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:41d98430-c872-48cc-a292-6044588320df</guid><dc:creator>danielh0002</dc:creator><description>&lt;p&gt;I&amp;#39;ve accomplished this effectively using these three expression rules:&lt;br /&gt;&lt;br /&gt;extractKeysFromDictionary:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!forEach(
  items: xpathsnippet(toxml(ri!dictionary), &amp;quot;/*/*&amp;quot;),
  expression: index(split(index(split(fv!item, &amp;quot; &amp;quot;), 1), &amp;quot;&amp;lt;&amp;quot;), 2)
)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;extractValuesFromDictionary:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!forEach(
  items: rule!extractKeysFromDictionary(ri!dictionary),
  expression: property(ri!dictionary, fv!item)
)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;combineDictionaries:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;reduce(
  fn!insert,
  ri!dictionary1,
  merge(
    rule!extractValuesFromDictionary(ri!dictionary2),
    rule!extractKeysFromDictionary(ri!dictionary2)
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/50107?ContentTypeID=1</link><pubDate>Wed, 15 Nov 2017 11:44:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:56002923-b961-499c-9152-1d6b45eb6e65</guid><dc:creator>swapnac</dc:creator><description>I think you can create new Dictionary by passing this existing dictionary using foreach() or apply&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/50098?ContentTypeID=1</link><pubDate>Wed, 15 Nov 2017 06:28:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4174cbad-0319-482b-b697-0b098a8f07d6</guid><dc:creator>Philip Snyman</dc:creator><description>&lt;p&gt;Hi Mike,&lt;/p&gt;
&lt;p&gt;Thanks. I have in the meantime however come up with a solution that doesn&amp;#39;t require any additional plugins. See below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;with(
  local!dictionary: cast(&amp;#39;type!{http://www.appian.com/ae/types/2009}Dictionary&amp;#39;, {}),
  local!fields: {&amp;quot;field1&amp;quot;, &amp;quot;field2&amp;quot;},
  local!values: {&amp;quot;value1&amp;quot;, &amp;quot;value2&amp;quot;},
  reduce(
    fn!insert(_, _, _),
    local!dictionary,
    merge(
      local!values,
      local!fields
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards,&lt;/p&gt;
&lt;p&gt;Philip Snyman&lt;/p&gt;
&lt;p&gt;&lt;a href="/discussions/f/rules/p/50084/reply/iam-app.co" target="_blank"&gt;I Am App South Africa&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/50084?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2017 20:15:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e152e5e5-5552-41a5-bf66-93217caaeeaa</guid><dc:creator>Mike Schmitt</dc:creator><description>You probably need to look into the CDT Manipulation plug-in, which has the &amp;quot;JoinCdts()&amp;quot; rule, which based on the limited detail you&amp;#39;ve provided, i&amp;#39;m guessing is your closest bet.&lt;br /&gt;
&lt;br /&gt;
Also, AFAIK a!flatten() doesn&amp;#39;t handle this use case - it is more for creating a single flat array of results when using looping functions might return arrays of arrays which can be confusing to deal with.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge Dictionaries</title><link>https://community.appian.com/thread/50079?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2017 19:07:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:14f4f219-cffe-4f07-aeaf-4529186ed741</guid><dc:creator>Ramesh Gudipati</dc:creator><description>You can try using a!flatten().&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>