<?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 a field based on indexing</title><link>https://community.appian.com/discussions/f/data/35459/update-a-field-based-on-indexing</link><description>I have two variables of list type, 
 local!selecteddata: { id:1, name:test1, id:4,name:test4}. 
 local!data:{id:1,name:test1, 
 id:2,name:test2, 
 id2,name:test3, 
 id4,name:test4 
 } 
 
 if I update the &amp;quot;name&amp;quot; fields of l ocal!selecteddata,How do I index</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138225?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2024 19:01:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fdabe074-fc9d-41ba-afd5-f9a2371baaa3</guid><dc:creator>kowsalyavijayan</dc:creator><description>&lt;p&gt;Thanks it worked&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138202?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2024 04:01:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6e43821d-9af4-4911-bda8-bd961cd6798a</guid><dc:creator>venkatrea696188</dc:creator><description>&lt;p&gt;Wrap it inside &lt;strong&gt;tointeger() and isn&amp;#39;t it in reverse??&amp;nbsp;&lt;/strong&gt;You want to update local!X&amp;nbsp; and update why you are giving direct record field reference??&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!update(
local!X[record.name],
wherecontains(tointeger(local!Y.id),tointeger(local!X[recordname.id])),
local!Y.name)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138196?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 18:38:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:07c20d5e-0dad-4644-b61f-737dd9616d4c</guid><dc:creator>kowsalyavijayan</dc:creator><description>&lt;p&gt;works perfect for local variable , but for record type , it throws error&amp;nbsp;a!localVariables(&lt;br /&gt; local!Y: {&lt;br /&gt; a!map(id: 1, name: &amp;quot;test5&amp;quot;),&lt;br /&gt; a!map(id: 4, name: &amp;quot;test6&amp;quot;)&lt;br /&gt; },&lt;br /&gt; local!X: a!queryRecordType(&lt;br /&gt; recordType: &amp;#39;recordType!{a765be9a-3396-4105-8e82-56074696a931}LMS Test&amp;#39;,&lt;br /&gt; fields: {},&lt;br /&gt; pagingInfo: a!pagingInfo(&lt;br /&gt; startIndex: 1,&lt;br /&gt; batchSize: 100&lt;br /&gt; )&lt;br /&gt; ).data,&lt;br /&gt; {&lt;br /&gt; a!buttonArrayLayout(&lt;br /&gt; buttons: {&lt;br /&gt; a!buttonWidget(&lt;br /&gt; label: &amp;quot;Button&amp;quot;,&lt;br /&gt; style: &amp;quot;OUTLINE&amp;quot;,&lt;br /&gt; saveInto: a!save(&lt;br /&gt; local!X['recordType!{a765be9a-3396-4105-8e82-56074696a931}LMS Test.fields.{74a22d07-4f83-4cc6-b8e8-1d3ff4bb620e}name'],&lt;br /&gt; a!update(&lt;br /&gt; &amp;#39;recordType!{a765be9a-3396-4105-8e82-56074696a931}LMS Test.fields.{74a22d07-4f83-4cc6-b8e8-1d3ff4bb620e}name&amp;#39;,&lt;br /&gt; {&lt;br /&gt; wherecontains(&lt;br /&gt; local!X['recordType!{a765be9a-3396-4105-8e82-56074696a931}LMS Test.fields.{0804dc2d-19ac-41c7-aee2-cae30a26dd96}id'],&lt;br /&gt; tointeger(local!Y.id)&lt;br /&gt; &lt;br /&gt; )&lt;br /&gt; },&lt;br /&gt; { local!Y.name }&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt; )&lt;br /&gt; },&lt;br /&gt; align: &amp;quot;START&amp;quot;,&lt;br /&gt; marginBelow: &amp;quot;NONE&amp;quot;&lt;br /&gt; )&lt;br /&gt; }&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/16/pastedimage1721155126676v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;error :&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/16/pastedimage1721155082047v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138184?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 16:51:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cfa14cb2-3a53-4c58-a7bd-26dd0dceac54</guid><dc:creator>venkatrea696188</dc:creator><description>[quote userid="248371" url="~/discussions/f/data/35459/update-a-field-based-on-indexing/138178"]tried this, but local!data lost rows with id 2 and id 4, because we are saving only two updated rows into this variable)[/quote]
&lt;p&gt;Yeah Update returns the result.. So need to careful with what you are indexing. Have a look into the below template&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!Y: {
    a!map(id: 1, name: &amp;quot;test5&amp;quot;),
    a!map(id: 4, name: &amp;quot;test6&amp;quot;)
  },
  local!X: {
    a!map(id: 1, name: &amp;quot;test1&amp;quot;),
    a!map(id: 2, name: &amp;quot;test2&amp;quot;),
    a!map(id: 3, name: &amp;quot;test3&amp;quot;),
    a!map(id: 4, name: &amp;quot;test4&amp;quot;)
  },
  {
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Button&amp;quot;,
          style: &amp;quot;OUTLINE&amp;quot;,
          saveInto: a!save(
            local!X.name,
            a!update(
              local!X.name,
              {
                wherecontains(
                  tointeger(local!Y.id),
                  tointeger(local!X.id)
                )
              },
              { local!Y.name }
            )
          )
        )
      },
      align: &amp;quot;START&amp;quot;,
      marginBelow: &amp;quot;NONE&amp;quot;
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138178?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 15:47:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:28036143-76f5-4a9a-bdcb-233b43ab8039</guid><dc:creator>kowsalyavijayan</dc:creator><description>&lt;p&gt;tried this, but local!data lost rows with id 2 and id 4, because we are saving only two updated rows into this variable)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138177?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 15:36:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:187ebcce-ec7a-40c4-b082-d48c61cfdc98</guid><dc:creator>Konduru Chaitanya</dc:creator><description>&lt;p&gt;you can use the same what Venkat has mentioned in the buttons saveInto parameter.&lt;/p&gt;
&lt;p&gt;a!save(target: local!data,value: a!update())&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138176?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 15:33:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3be559c5-4475-4efd-8282-1f9d60a82bc4</guid><dc:creator>kowsalyavijayan</dc:creator><description>&lt;p&gt;how can I so this upon button click&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138175?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 15:32:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:25614fae-ea85-40a1-b22e-3a5700a3a634</guid><dc:creator>kowsalyavijayan</dc:creator><description>&lt;p&gt;thanks for the reply, is there a way , I can do this inside a button. my requirement is upon button click , I need to update.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138163?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 13:56:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c5ebbc28-7a33-4d89-b6ae-54bbc648031a</guid><dc:creator>rajthakor</dc:creator><description>&lt;p&gt;you can also use &lt;strong&gt;a!forEach&amp;nbsp;&lt;/strong&gt;function&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update a field based on indexing</title><link>https://community.appian.com/thread/138122?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2024 05:03:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:85ffb43a-2e81-4874-944e-e0ed2b733a71</guid><dc:creator>venkatrea696188</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!Y: {
    a!map(id: 1, name: &amp;quot;test5&amp;quot;),
    a!map(id: 4, name: &amp;quot;test6&amp;quot;)
  },
  local!X: {
    a!map(id: 1, name: &amp;quot;test1&amp;quot;),
    a!map(id: 2, name: &amp;quot;test2&amp;quot;),
    a!map(id: 3, name: &amp;quot;test3&amp;quot;),
    a!map(id: 4, name: &amp;quot;test4&amp;quot;)
  },
  a!update(
    local!X,
    wherecontains(local!Y.id, local!X.id),
    local!Y
  )
)

-------------------------------------------------------------

a!localVariables(
  local!Y: {
    a!map(id: 1, name: &amp;quot;test7&amp;quot;),
    a!map(id: 4, name: &amp;quot;test8&amp;quot;)
  },
  local!X: {
    a!map(id: 1, name: &amp;quot;test1&amp;quot;),
    a!map(id: 2, name: &amp;quot;test2&amp;quot;),
    a!map(id: 3, name: &amp;quot;test3&amp;quot;),
    a!map(id: 4, name: &amp;quot;test4&amp;quot;)
  },
  a!update(
    local!X,
    &amp;quot;name&amp;quot;,
    a!update(
      local!X.name,
      wherecontains(local!Y.id, local!X.id),
      local!Y.name
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It can be achieved multiple ways. use &lt;strong&gt;Wherecontains()&amp;nbsp;&lt;/strong&gt;to index based on &lt;strong&gt;id&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>