<?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>Append Values</title><link>https://community.appian.com/discussions/f/rules/28376/append-values</link><description>Hi, 
 I have a requirement to append the values of a particular computation to a local variable using append function 
 The rule goes like this : 
 a!localVariables( 
 local!data : {&amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot;, }, 
 local!finalValues, 
 a!forEach( 
 items: local!data</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Append Values</title><link>https://community.appian.com/thread/111043?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 17:45:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dfe01443-ee51-4281-b3e0-03ff4b46c568</guid><dc:creator>GautamShenoy</dc:creator><description>&lt;p&gt;This works thank you&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Append Values</title><link>https://community.appian.com/thread/111042?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 17:45:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d8370b02-10b5-4c0d-a34e-475c2586279b</guid><dc:creator>GautamShenoy</dc:creator><description>&lt;p&gt;Thanks it works&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Append Values</title><link>https://community.appian.com/thread/111038?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 16:53:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:68e68041-f782-41cc-af89-695bc835a927</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Also you would not need &amp;quot;append()&amp;quot; here - simply assemble your array.&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/15/pastedimage1681404886777v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!data: { &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot;,  },
  local!finalValues: a!forEach(
    items: local!data,
    expression: performSomeComputation(fv!item)
  ),
  
  local!finalValues /* for the sake of output only */
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Append Values</title><link>https://community.appian.com/thread/111037?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 16:52:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c4c2e766-8d76-403b-a859-1d56f42bf116</guid><dc:creator>Amaan Shekh</dc:creator><description>&lt;p&gt;try this-&amp;gt;&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/15/pastedimage1681404814458v1.png" alt=" " /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: { &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot;,  },
  local!finalValues: a!forEach(
    items: local!data,
    expression: concat(&amp;quot;&amp;#39;&amp;quot;, fv!item) /*some computation*/
  ),
  local!finalValues
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Append Values</title><link>https://community.appian.com/thread/111036?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 16:51:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ead7eb6b-76ee-4ba2-b8a5-f82c3e78714e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You would need to &lt;em&gt;&lt;strong&gt;define&lt;/strong&gt;&lt;/em&gt; local!finalValues &lt;em&gt;&lt;strong&gt;as&lt;/strong&gt;&lt;/em&gt; the a!forEach() update sequence you try below.&amp;nbsp; Expression code can&amp;#39;t and doesn&amp;#39;t &amp;quot;push&amp;quot; a value into an already-defined variable (the only exception being on a form where saves are executed via user interaction) - instead you need to build the update into your definitions.&amp;nbsp; It can be a tricky paradigm to get used to, I admit, but once you get it, it&amp;#39;s pretty easy to follow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>