<?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>How to find the first target element in an array</title><link>https://community.appian.com/discussions/f/rules/19240/how-to-find-the-first-target-element-in-an-array</link><description>Hi all dears, 
 
 currently i need to find a specific fruit and give it a value, however the fruit name in the array may be duplicate and i need to give value only for the first one appeared the array: 
 For example: 
 Rule Inputs: 
 fruits(5 items) </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to find the first target element in an array</title><link>https://community.appian.com/thread/75338?ContentTypeID=1</link><pubDate>Sat, 11 Jul 2020 10:13:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2d50cc4c-513c-4b58-a922-7bb01bacb0b4</guid><dc:creator>freyFyLiu</dc:creator><description>&lt;p&gt;Hi Harshit,&lt;/p&gt;
&lt;p&gt;Thanks for your great help and your solution works very well now.&lt;/p&gt;
&lt;p&gt;I just take the fruit as an simple to demonstrate the issue i&amp;#39;m facing, the real scenario is more complex than this, sorry for you confuse and thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find the first target element in an array</title><link>https://community.appian.com/thread/75330?ContentTypeID=1</link><pubDate>Fri, 10 Jul 2020 17:25:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4e7f633a-bdd0-4145-a8c1-a0790e772c0a</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="/members/freyfyl0001"&gt;freyFyLiu&lt;/a&gt;,&lt;br /&gt;I think this code snippet will work for you. However I am confused about the scenario where you only have to assign one value. You can give the below code a try and see if it resolves your problem.&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!fruits: {
    {
      fruitName: &amp;quot;apple&amp;quot;,
      price: &amp;quot;&amp;quot;
    },
    {
      fruitName: &amp;quot;banana&amp;quot;,
      price: &amp;quot;&amp;quot;
    },
    {
      fruitName: &amp;quot;banana&amp;quot;,
      price: &amp;quot;&amp;quot;
    },
    {
      fruitName: &amp;quot;peach&amp;quot;,
      price: &amp;quot;&amp;quot;
    },
    {
      fruitName: &amp;quot;peach&amp;quot;,
      price: &amp;quot;&amp;quot;
    }
  },
  local!fruitFlag: &amp;quot;banana&amp;quot;,
  local!fruitIndex: index(wherecontains(local!fruitFlag,touniformstring(property(local!fruits,&amp;quot;fruitName&amp;quot;))),1,{}),
  a!forEach(
    items: local!fruits,
    expression: {
      fruitName: fv!item.fruitName,
      price: if(
        and(
          fv!item.fruitName=local!fruitFlag,
          fv!index=local!fruitIndex
        ),
        100,
        fv!item.price
      )
    }
  )
)&lt;/pre&gt;&lt;br /&gt;Thanks,&lt;br /&gt;-Harshit&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>