<?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>Appending Map with keys and values from second map</title><link>https://community.appian.com/discussions/f/data/37817/appending-map-with-keys-and-values-from-second-map</link><description>Good day experts! I am attempting to merge two maps and have gone thru many examples from the forum but can&amp;#39;t seem to get those solutions to work for my use case. 
 I have two maps that have different key value pairs that I want to merge into one map</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Appending Map with keys and values from second map</title><link>https://community.appian.com/thread/142141?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2024 13:41:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:43d72c49-3222-41b9-9368-83dccad892b5</guid><dc:creator>John Barker</dc:creator><description>&lt;p&gt;Thank you so much Shanmathi!&amp;nbsp; This worked like a charm!&amp;nbsp; I was struggling with how to get the values array to line up with the keys that I wanted to add to the first map.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Appending Map with keys and values from second map</title><link>https://community.appian.com/thread/142118?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2024 06:01:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:08d00f5a-dec4-4bc8-9f68-e1053cc9ea26</guid><dc:creator>Prasanta Paul</dc:creator><description>&lt;p&gt;If you want to update, you can use a!update() function&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Appending Map with keys and values from second map</title><link>https://community.appian.com/thread/142114?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2024 00:33:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7a18063c-30ef-4dbd-8d5b-67be189b4814</guid><dc:creator>Shanmathi Ponnusamy</dc:creator><description>&lt;p&gt;HI &lt;a href="/members/johnb0013"&gt;John Barker&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;You want all the keys and values in queueMap to be appened to corresponding participantMap. Please refer below code&amp;nbsp;and is this what you expected.&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!participantMap: {
    a!map(
      participantId: 3402,
      blockId: 881,
      policyNumber: &amp;quot;VF80U16350&amp;quot;,
      policyEffectiveDate: fn!date(2023, 9, 25),
      dateOfBith: null,
      firstName: &amp;quot;Bill&amp;quot;,
      lastName: &amp;quot; Johnson&amp;quot;,
      middleInitial: &amp;quot;W&amp;quot;,
      ssn: &amp;quot;123456789&amp;quot;,
      genderRefId: 68,
      suffixRefId: 63,
      statusRefId: 1032
    ),
    a!map(
      participantId: 3401,
      blockId: 881,
      policyNumber: &amp;quot;VF80U16340&amp;quot;,
      policyEffectiveDate: fn!date(2023, 9, 25),
      dateOfBith: fn!date(1996, 7, 4),
      firstName: &amp;quot;Robert&amp;quot;,
      lastName: &amp;quot;Martinez&amp;quot;,
      middleInitial: &amp;quot;J&amp;quot;,
      ssn: &amp;quot;213456689&amp;quot;,
      genderRefId: 69,
      suffixRefId: 66,
      statusRefId: 1093
    )
  },
  local!queueMap: {
    a!map(
      queueId: 3354,
      blockId: 881,
      participantId: 3402,
      appianGroupId: 58,
      assigneeUsername: &amp;quot;Karl.Seager@test.com&amp;quot;,
      isActive: true,
      modifiedOn: fn!datetime(2024, 7, 18, 13, 31, 49, 0),
      lastAssignee: &amp;quot;&amp;quot;,
      lastAssignedGroup: 25
    ),
    a!map(
      queueId: 3356,
      blockId: 881,
      participantId: 3401,
      appianGroupId: 58,
      assigneeUsername: &amp;quot;Karl.Seager@test.com&amp;quot;,
      isActive: true,
      modifiedOn: fn!datetime(2024, 7, 18, 13, 31, 49, 0),
      lastAssignee: &amp;quot;&amp;quot;,
      lastAssignedGroup: 25
    )
  },
  local!queueKeys: a!keys(index(local!queueMap, 1, {})),
  local!updatedMap: a!forEach(
    items: local!participantMap,
    expression: a!localVariables(
      local!currentParticipantItem: fv!item,
      local!currentParticipantQueue: index(
        local!queueMap,
        wherecontains(
          tointeger(
            index(
              local!currentParticipantItem,
              &amp;quot;participantId&amp;quot;,
              null
            )
          ),
          tointeger(
            index(local!queueMap, &amp;quot;participantId&amp;quot;, null)
          )
        ),
        null
      ),
      local!queueKeysValuesArray: a!forEach(
        items: local!queueKeys,
        expression: index(
          local!currentParticipantQueue,
          fv!item,
          null
        )
      ),
      a!update(
        fv!item,
        local!queueKeys,
        local!queueKeysValuesArray
      )
    )
  ),
  local!updatedMap
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>