<?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>Array Expression</title><link>https://community.appian.com/discussions/f/new-to-appian/18596/array-expression</link><description>Hi guys/gals, Some help please with an expression rule I&amp;#39;m trying to create that&amp;#39;s driving me nuts. Here&amp;#39;s the simple example: 
 a!localVariables( local!array: { { id: 1, deleted: true, activeStep: false }, { id: 2, deleted: false, activeStep: false </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Array Expression</title><link>https://community.appian.com/thread/73218?ContentTypeID=1</link><pubDate>Fri, 10 Apr 2020 05:39:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3b3550dd-c8a3-4431-b1ed-d1e68af011c4</guid><dc:creator>randolpho0001</dc:creator><description>&lt;p&gt;Thanks, Pete... exactly what I need.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Array Expression</title><link>https://community.appian.com/thread/73201?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 12:59:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c48b159c-84ff-4a21-a380-2ef9f666b882</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Yeah that seems fine to me - you could also use updatearray() if you want to update only that row and not use a!forEach(). Here&amp;#39;s an example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!array:
  {
    { id: 1, deleted: true, activeStep: false },
    { id: 2, deleted: false, activeStep: false },
    { id: 3, deleted: false, activeStep: false },
  },
  local!rowToUpdate: tointeger(min(where(not(tointeger(local!array.deleted))))),
  local!itemToUpdate: index(local!array, local!rowToUpdate, {}), 
  updatearray(
    local!array,
    local!rowToUpdate,
    {
      id: index(local!itemToUpdate, &amp;quot;id&amp;quot;, null),
      deleted: false,
      activeStep: true
    }
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Array Expression</title><link>https://community.appian.com/thread/73196?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 09:11:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6e1f0574-ff43-4f2d-a25a-1ad46c587972</guid><dc:creator>randolpho0001</dc:creator><description>&lt;p&gt;Hi harshav, Thanks for that. Problem is it&amp;#39;s not always the first index. It&amp;#39;s the minimum index where the deleted field is false.&lt;/p&gt;
&lt;p&gt;I just got this working below by finding that minimum index first, but would love to know if there&amp;#39;s a more ideal way.&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt;&amp;nbsp; local!array:&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; { id: 1, deleted: true, activeStep: false },&lt;br /&gt;&amp;nbsp; &amp;nbsp; { id: 2, deleted: false, activeStep: false },&lt;br /&gt;&amp;nbsp; &amp;nbsp; { id: 3, deleted: false, activeStep: false },&lt;br /&gt;&amp;nbsp; },&lt;br /&gt;&amp;nbsp; local!rowToUpdate: min(wherecontains(&amp;quot;false&amp;quot;, split(tostring(local!array.deleted), &amp;quot;; &amp;quot;))),&lt;br /&gt; &amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; a!forEach(&lt;br /&gt;&amp;nbsp; &amp;nbsp; local!array,&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(fv!index=local!rowToUpdate,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {id: fv!item.id, deleted: fv!item.deleted, activeStep: true},&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; fv!item&lt;br /&gt;&amp;nbsp; &amp;nbsp; )&lt;br /&gt;&amp;nbsp; )&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Array Expression</title><link>https://community.appian.com/thread/73195?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 08:59:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:547c553f-3d90-4db2-b6cc-e09b3045f555</guid><dc:creator>harshav</dc:creator><description>&lt;p&gt;Try it using a!foreach but change your logic like this,&lt;/p&gt;
&lt;p&gt;a!foreach(&lt;/p&gt;
&lt;p&gt;items: local!array,&lt;/p&gt;
&lt;p&gt;expression: if(fv!index = 1,&lt;/p&gt;
&lt;p&gt;set the value which you want to true , else fv!item)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>