<?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 Array Recursively</title><link>https://community.appian.com/discussions/f/general/22408/update-array-recursively</link><description>Hi, 
 I am trying to update an array of CDTs recursively. 
 Base Array : 
 { {name:&amp;quot;Alex&amp;quot;,rollNumber:null}, {name:&amp;quot;Stephen&amp;quot;,rollNumber:3}, {name:&amp;quot;Dave&amp;quot;,rollNumber:4}, {name:&amp;quot;Steave&amp;quot;,rollNumber:5}, {name:&amp;quot;Rosey&amp;quot;,rollNumber:7}, {name:&amp;quot;John&amp;quot;,rollNumber:8</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87740?ContentTypeID=1</link><pubDate>Mon, 08 Nov 2021 07:55:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:941b4243-7f56-4b3e-aef7-30bcd911e66a</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;OK. So to keep the data in a specific order, the actual values do not matter as long as they are ascending and unique.&lt;/p&gt;
&lt;p&gt;A code snippet similar to the below, should update the rollNumbers. There is no complex logic necessary.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!forEach(
  items: local!list,
  expression: a!update(
    fv!item,
    &amp;quot;rollNumber&amp;quot;,
    fv!index
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87737?ContentTypeID=1</link><pubDate>Mon, 08 Nov 2021 06:58:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:33a3cdf5-a44e-4b95-a651-dd2f98e5f8e7</guid><dc:creator>shamima0001</dc:creator><description>&lt;p&gt;To answer your questions, please have a look on the inline comments :&lt;/p&gt;
&lt;p&gt;Where is that data coming from? [ Data is coming form a table in database ]&lt;/p&gt;
&lt;p&gt;Is this the whole list or just a part of it? [ it is the whole list ]&lt;/p&gt;
&lt;p&gt;What is the meaning of that &amp;quot;rollNumber&amp;quot;? [ '"rollNumber" is an integer value field]&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is it used in other table as a foreign key or something? Sorting? [ It is not used in other table as foreign key, but used to sort the whole table data]&lt;/p&gt;
&lt;p&gt;Then, how is that data added? By a user in an interface? [ data is added from a dropdown in an interface]&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope this answers your question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87735?ContentTypeID=1</link><pubDate>Mon, 08 Nov 2021 06:50:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:08f39e65-94e3-4fcc-a95c-a996b7943b72</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Hm ... this really depends on your actual use case.&lt;/p&gt;
&lt;p&gt;Where is that data coming from? Is this the whole list or just a part of it? What is the meaning of that &amp;quot;rollNumber&amp;quot;? Is it used in other table as a foreign key or something? Sorting?&lt;/p&gt;
&lt;p&gt;Then, how is that data added? By a user in an interface?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87734?ContentTypeID=1</link><pubDate>Mon, 08 Nov 2021 06:20:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:44fc3ee9-2364-47c2-8af7-96d03980bc6e</guid><dc:creator>shamima0001</dc:creator><description>&lt;p&gt;Can you help me understand with an example, please ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87725?ContentTypeID=1</link><pubDate>Sat, 06 Nov 2021 15:14:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9daac023-4ac8-49b2-a633-e5927836d309</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Why not just add the names and then renumber the whole list? That would be easy to do with a foreach and a!update.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87724?ContentTypeID=1</link><pubDate>Sat, 06 Nov 2021 14:28:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:43272e42-4c6b-4fb2-884b-5c3ac083124b</guid><dc:creator>shamima0001</dc:creator><description>&lt;p&gt;My apologies, actually its not just&amp;nbsp;array of integers but array of CDTs. I have updated the question above.&lt;/p&gt;
&lt;p&gt;Please help me with it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Array Recursively</title><link>https://community.appian.com/thread/87706?ContentTypeID=1</link><pubDate>Fri, 05 Nov 2021 16:09:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fa3bbbab-363e-4357-ab4b-89c910e4e986</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Like a lot of problems, you can break this down into smaller problems to solve.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;solve how to take you array and insert ONE new value into it
&lt;ol&gt;
&lt;li&gt;solve inserting a value that doesn&amp;#39;t yet exist in the array&lt;/li&gt;
&lt;li&gt;solve inserting a value that does exist in the array&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;solve how to invoke the above for a list of values&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For 1 you can write an expression rule that takes as its input your array of&amp;nbsp;integers that you want to modify and a single integer that you want to insert into the array.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For 2 there is the reduce() function which you can use to recursively call your new expression.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>