<?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>Update specific field on specific index</title><link>https://community.appian.com/discussions/f/data/21632/update-specific-field-on-specific-index</link><description>Hello All, 
 
 I just want to know how can I update a specific field to a specific index? example is I have 3 list of items, and I only want to update the 2nd index first name to &amp;quot;Jerry&amp;quot; and not &amp;quot;Henry&amp;quot;. I tried to use updatearray() but its only updating</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84614?ContentTypeID=1</link><pubDate>Mon, 16 Aug 2021 12:53:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:be4f0917-42b6-4aba-aa35-d43c3d406f78</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;You can still use a!update(), just use a!forEach() instead of the first update:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    { index: 1, name: &amp;quot;John&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
    { index: 2, name: &amp;quot;Henry&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
    { index: 3, name: &amp;quot;Jenny&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
  },
  a!forEach(
    items: local!data,
    expression: if(
      fv!index = 2,
      a!update(
        data: index(local!data, 2, {}),
        index: &amp;quot;name&amp;quot;,
        value: &amp;quot;Jerry&amp;quot;
      ),
      if(
        fv!index = 3,
        a!update(
          data: index(local!data, 3, {}),
          index: &amp;quot;name&amp;quot;,
          value: &amp;quot;Justine&amp;quot;
        ),
        fv!item
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84586?ContentTypeID=1</link><pubDate>Sat, 14 Aug 2021 02:14:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a480d9f1-4d66-4c6a-8ec4-d07f46e821aa</guid><dc:creator>rainier_albario</dc:creator><description>&lt;p&gt;Here&lt;br /&gt;&lt;br /&gt;a!localVariables(&lt;br /&gt; local!data: {&lt;br /&gt; { index: 1, name: &amp;quot;John&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },&lt;br /&gt; { index: 2, name: &amp;quot;Henry&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },&lt;br /&gt; { index: 3, name: &amp;quot;Jenny&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },&lt;br /&gt; },&lt;br /&gt; local!result: a!forEach(&lt;br /&gt; items: local!data,&lt;br /&gt; expression: if(&lt;br /&gt; fv!index= 2,&lt;br /&gt; updatedictionary(&lt;br /&gt; fv!item,&lt;br /&gt; {&lt;br /&gt; name: &amp;quot;Jerome&amp;quot;&lt;br /&gt; }&lt;br /&gt; ),&lt;br /&gt; fv!item&lt;br /&gt; )&lt;br /&gt; ),&lt;br /&gt; a!forEach(&lt;br /&gt; items: local!result,&lt;br /&gt; expression: if(&lt;br /&gt; fv!index= 3,&lt;br /&gt; updatedictionary(&lt;br /&gt; fv!item,&lt;br /&gt; {&lt;br /&gt; name: &amp;quot;Justine&amp;quot;&lt;br /&gt; }&lt;br /&gt; ),&lt;br /&gt; fv!item&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84585?ContentTypeID=1</link><pubDate>Sat, 14 Aug 2021 02:10:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:00ecdbc1-bed0-4094-b3ad-752e9607c63a</guid><dc:creator>rainier_albario</dc:creator><description>&lt;p&gt;Okay. I tried calling another forEach to update the 3rd index and it worked. Just wanna know if that&amp;#39;s a good way to do that?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84584?ContentTypeID=1</link><pubDate>Sat, 14 Aug 2021 02:01:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a9db8b27-68a4-4d1e-b701-dd2c25b830c0</guid><dc:creator>rainier_albario</dc:creator><description>&lt;p&gt;Hello Peter, Thank you for your reply. I tried this but I can&amp;#39;t update multiple data. ex. 2nd and 3rd index&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84583?ContentTypeID=1</link><pubDate>Sat, 14 Aug 2021 01:36:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e0e0fbb4-3229-43da-9052-3b6caefb0854</guid><dc:creator>rainier_albario</dc:creator><description>&lt;p&gt;Sorry for the late reply. I tried this&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if the index is 1 and 2 the value should be both updated. but its not working as expected on my end only one can be updated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84582?ContentTypeID=1</link><pubDate>Fri, 13 Aug 2021 21:04:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:595165bb-44ee-4803-a21e-cc42e4860d9a</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;As an alternative for prior versions of Appian, the &lt;a href="/b/appmarket/posts/cdt-manipulation"&gt;Dictionary Manipulation&lt;/a&gt; plugin is very useful for these sorts of things:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!data: {
    { index: 1, name: &amp;quot;John&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
    { index: 2, name: &amp;quot;Henry&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
    { index: 3, name: &amp;quot;Jenny&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
  },
  
  a!forEach(
    items: local!data,
    expression: if(
      fv!index=2,
      updatedictionary(
        fv!item,
        {
          name: &amp;quot;Jerry&amp;quot;
        }
      ),
      fv!item
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update specific field on specific index</title><link>https://community.appian.com/thread/84581?ContentTypeID=1</link><pubDate>Fri, 13 Aug 2021 20:55:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b39b8d2a-9bd8-44d9-b882-234fa7c5de71</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Are you on 21.2? There&amp;#39;s a great function that was recently released called &lt;a href="https://docs.appian.com/suite/help/latest/fnc_array_a_update.html"&gt;a!update()&lt;/a&gt; that makes this pretty easy. The only tricky thing is that since you&amp;#39;re updating a single value in a list of lists, you have to perform a!update() twice. Here&amp;#39;s an example of how it works:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    { index: 1, name: &amp;quot;John&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
    { index: 2, name: &amp;quot;Henry&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
    { index: 3, name: &amp;quot;Jenny&amp;quot;, lastName: &amp;quot;Doe&amp;quot; },
  },
  a!update(
    data: local!data,
    index: 2,
    value: a!update(
      data: index(local!data, 2, {}),
      index: &amp;quot;name&amp;quot;,
      value: &amp;quot;Jerry&amp;quot;
    ),
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>