<?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>Extending new keys to Map array</title><link>https://community.appian.com/discussions/f/rules/37814/extending-new-keys-to-map-array</link><description>Hello everyone, 
 Please have a look at below code: 
 here i want to extend array1 map key from array2, which is dynamically generated through array2 and values should be the value of id from array1. 
 so i am expecting the new array would be like this</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Extending new keys to Map array</title><link>https://community.appian.com/thread/142113?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2024 20:34:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7fe6abed-0be7-4cdc-aef3-8272bef0b796</guid><dc:creator>Shanmathi Ponnusamy</dc:creator><description>&lt;p&gt;&amp;nbsp;Hi &lt;a href="/members/shahidsalamk0001"&gt;Shahid&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is this what you are expecting? Here as you said&amp;nbsp;, array 2 is dynamic and map in Array 1 takes the key from array 2 and update it with its ID.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!array1: {
    a!map(id: 12, name: &amp;quot;Name1&amp;quot;),
    a!map(id: 44, name: &amp;quot;Name2&amp;quot;)
  },
  local!array2: {
    fullName: &amp;quot;john&amp;quot;,
    address: &amp;quot;ABC&amp;quot;,
    phoneNum: &amp;quot;876546&amp;quot;,
    gender: &amp;quot;Male&amp;quot;,
    company: &amp;quot;XYZ&amp;quot;,
    dept:&amp;quot;IT&amp;quot;
  },
  local!labelNamesInArray2: a!keys(local!array2),
  local!n: length(local!labelNamesInArray2),
  a!forEach(
    items: local!array1,
    expression: a!localVariables(
      local!id: index(fv!item, &amp;quot;id&amp;quot;, null),
      a!update(
        fv!item,
        local!labelNamesInArray2,
        repeat(local!n, local!id)
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Extending new keys to Map array</title><link>https://community.appian.com/thread/142109?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2024 18:30:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:972f0d49-081f-4d43-b868-5d8397d77b26</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;&lt;span&gt;Can I win something here?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!array1: {
    a!map(id: 1, name: &amp;quot;Name1&amp;quot;),
    a!map(id: 2, name: &amp;quot;Name2&amp;quot;)
  },
  local!n: 10,
  a!forEach(
    items: local!array1,
    expression: a!update(
      fv!item,
      apply(concat(_,_), merge(repeat(local!n, &amp;quot;key&amp;quot;), 1+enumerate(local!n))),
      repeat(local!n, fv!index)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;BTW, the apply() can be replaced by a foreach().&lt;/p&gt;
&lt;p&gt;Where is this challenge coming from?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Extending new keys to Map array</title><link>https://community.appian.com/thread/142108?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2024 18:21:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a68d880f-6711-4ff0-8d08-7e10eb9c7b85</guid><dc:creator>Shahid</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="/members/stefanhelzle0001"&gt;Stefan Helzle&lt;/a&gt;&amp;nbsp;you just hard coded the keys , in my case the number of keys can increase or decrease.&lt;/p&gt;
&lt;p&gt;consider enumerate(n) instead enumerate(10) for array2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Extending new keys to Map array</title><link>https://community.appian.com/thread/142107?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2024 18:18:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d78b271f-eae3-4717-a502-b1038f789fde</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Interesting exercise ...&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!array1: {
    a!map(id: 1, name: &amp;quot;Name1&amp;quot;),
    a!map(id: 2, name: &amp;quot;Name2&amp;quot;)
  },
  a!forEach(
    items: local!array1,
    expression: a!update(
      fv!item,
      {&amp;quot;key1&amp;quot;, &amp;quot;key2&amp;quot;, &amp;quot;key3&amp;quot;, &amp;quot;key4&amp;quot;, &amp;quot;key5&amp;quot;, &amp;quot;key6&amp;quot;, &amp;quot;key7&amp;quot;, &amp;quot;key8&amp;quot;, &amp;quot;key9&amp;quot;, &amp;quot;key10&amp;quot;},
      repeat(10, fv!index)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>