<?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 save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/discussions/f/general/21013/how-to-save-both-a-save-as-only-one-a-save-is-working-for-if-condition-in-allocation-type-5</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/thread/81858?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 16:16:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:61cd2ef1-403e-46e2-9fc4-1df8bcef9105</guid><dc:creator>Ross Boniquit</dc:creator><description>&lt;p&gt;Thank&amp;nbsp;you so much, Stefan and Mike! I did some tweaks on the code for the fv!item and it works &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/thread/81853?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 15:35:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2db09794-78db-4670-9d2c-b177a508165f</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="59361" url="~/discussions/f/general/21013/how-to-save-both-a-save-as-only-one-a-save-is-working-for-if-condition-in-allocation-type-5/81852#81852"]Have an expression which takes all necessary input, does some magic and creates a list of entityData items. You would call this expression directly at valuesToStore.[/quote]
&lt;p&gt;Also if you store your magic&amp;#39;d array in a local variable, it&amp;#39;s 100x easier to troubleshoot as you can just see the array values in the local variables panel in the interface editor.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/thread/81852?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 15:34:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ce9e71f4-941b-4eb6-858c-a88ea60364a2</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Interesting code ....&lt;/p&gt;
&lt;p&gt;I implement things like this in different way.&lt;/p&gt;
&lt;p&gt;Have an expression which takes all necessary input, does some magic and creates a list of entityData items. You would call this expression directly at valuesToStore.&lt;/p&gt;
&lt;p&gt;This way you separate this complex logic from the UI and keep it maintainable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/thread/81850?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 15:32:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:008cf58b-5a95-4976-992f-46c3f93fc8f6</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I suggest restructuring your saveInto.&amp;nbsp; Instead of looping over the array and trying to execute multiple (maybe dozens?) of individual saves within it, call the save once and use the a!forEach() function to assemble the altered array you&amp;#39;re after.&amp;nbsp; Until 20.2 is out you&amp;#39;ll need to use the &amp;quot;updateDictionary&amp;quot; plug-in function to accomplish this, but it shouldn&amp;#39;t be a problem hopefully.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!save(
  ri!sourceCashEntries,
  a!forEach(
    ri!sourceCashEntries,
    if(
      fv!item.allocationTypeId = 5,
      updateDictionary(
        fv!item,
        {
          suspenseIsOpen: true(),
          isAdjusted: false()
        }
      ),
      /* .... etc */
    )
  )
)
      
          &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/thread/81847?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 15:19:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dd3ada97-734d-41da-9db2-878799421c0f</guid><dc:creator>Ross Boniquit</dc:creator><description>&lt;p&gt;Thanks, Mike for your insight. Tried replacing it to fv!item however, the isadjusted is still not being updated to false&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to save both a!save as only one a!save is working for IF condition in allocation type = 5</title><link>https://community.appian.com/thread/81846?ContentTypeID=1</link><pubDate>Thu, 20 May 2021 15:12:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0bf6cab4-2f33-4138-9651-003686ed2bff</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Just with a quick glance - you&amp;#39;re looping over the ri!sourceCashEntries array using a!forEach, but then inside your forEach, instead of referring to the current item of the array using fv!item, you&amp;#39;re having your a!save() calls act directly on ri!sourceCashEntries (most notably, acting as if it were not an array).&amp;nbsp; Please try replacing &amp;quot;ri!sourceCashEntries.&amp;quot; with &amp;quot;fv!item.&amp;quot; on lines 25 and 26, and see if the behavior gets closer to what your expectations were.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>