<?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>Difference in load() with () and other functions</title><link>https://community.appian.com/discussions/f/general/18789/difference-in-load-with-and-other-functions</link><description>Hi folks, 
 
 Can anyone please tell me the difference between load(),with(), a!localvariable and a!refreshvariable functions. In what different scenarios are all these used. Is a!localvariable replacement of load and with both ? 
 It would be better</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73897?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:39:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:200b9d7c-d8e6-4d18-8d7e-2f349c7f0fe6</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Exactly - I really enjoy how much more easy and/or flexible things are now.&lt;/p&gt;
&lt;p&gt;And yes, if it doesn&amp;#39;t reference other variables, then it&amp;#39;s essentially a load() value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73896?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:37:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:76dd33dd-dcec-4962-89a2-e652a90d3a0e</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;Nice catch!&lt;/p&gt;
&lt;p&gt;It is really nice that they made the default so useful.&amp;nbsp; Now you can easily do things like run a queryEntity with a different parameter but only when the parameter actually changes.&lt;/p&gt;
&lt;p&gt;And I suppose if it doesn&amp;#39;t reference any other variables, it&amp;#39;s just a load() at that point, right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73894?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:28:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8749e1d1-8d8e-4d10-8da8-911f47b0e07e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Found your problem... you replaced&amp;nbsp;&lt;em&gt;with(),&lt;/em&gt; with &lt;em&gt;&lt;strong&gt;nothing&lt;/strong&gt;&lt;/em&gt;, instead of &lt;em&gt;a!localVariables()&lt;/em&gt;...&lt;br /&gt;&lt;a href="/members/stewart.burchell"&gt;Stewart Burchell&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1588858023116v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;should be:&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!myNestedArray: {
    {
      {record: 1, attributes: {&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;,&amp;quot;C&amp;quot;}},
      {record: 2, attributes: {&amp;quot;D&amp;quot;,&amp;quot;E&amp;quot;,&amp;quot;F&amp;quot;}}
    },
  },
  local!currentItem: null,
  a!forEach(
    items: local!myNestedArray,
    expression: a!localVariables(
      local!currentItem: fv!item.record,
      a!forEach(
        items: fv!item.attributes,
        expression: {
          local!currentItem,
          fv!item
        }
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1588858064106v2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73893?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:22:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:af99b818-8a7b-4565-9a16-51c2c9fa6e1a</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Because you can&amp;#39;t assign a value to a local!variable from within the scope of the a!forEach() - or, if you can, I&amp;#39;m not seeing how that&amp;#39;s done. Here&amp;#39;s&amp;nbsp;what I&amp;#39;ve just experimented with. First is what works using a with():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!myNestedArray: {
    {
      {record: 1, attributes: {&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;,&amp;quot;C&amp;quot;}},
      {record: 2, attributes: {&amp;quot;D&amp;quot;,&amp;quot;E&amp;quot;,&amp;quot;F&amp;quot;}}
    },
  },
  a!forEach(
    items: local!myNestedArray,
    expression: with(
      local!currentItem: concat(&amp;quot;SJB/&amp;quot;, fv!item.record),
      a!forEach(
        items: fv!item.attributes,
        expression: {
          local!currentItem,
          fv!item
        }
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;...and secondly here&amp;#39;s what I&amp;#39;ve tried to do just using local!variables (which I can&amp;#39;t get to work):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!myNestedArray: {
    {
      {record: 1, attributes: {&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;,&amp;quot;C&amp;quot;}},
      {record: 2, attributes: {&amp;quot;D&amp;quot;,&amp;quot;E&amp;quot;,&amp;quot;F&amp;quot;}}
    },
  },
  local!currentItem: null,
  a!forEach(
    items: local!myNestedArray,
    expression: {
      local!currentItem: fv!item.record,
      a!forEach(
        items: fv!item.attributes,
        expression: {
          local!currentItem,
          fv!item
        }
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Arguably (and I might take that position for more a more sophisticated transformation in the inner loop) you&amp;#39;d have a helper rule. And maybe that&amp;#39;s best practice, but I&amp;#39;m always (!) suspicious when someone is definitive in their reply! ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73892?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:22:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:179e8352-106f-4582-b5b2-1d55992a0cb9</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="26843" url="~/discussions/f/general/18789/difference-in-load-with-and-other-functions/73889"]Each of your&amp;nbsp;variables inside a!localVariables() should be defined with it&amp;#39;s own a!refreshVariable function.[/quote]
&lt;p&gt;I would differ on this point.&amp;nbsp; Local variables can also be defined simply with the value instead of the a!refreshVariable function, as long as the default functionality of a refresh variable is fine.&amp;nbsp; This includes refreshing on referenced variable change, NOT refreshing always, and not doing any of the more advanced refreshes.&amp;nbsp; I&amp;#39;d estimate that for maybe 80 - 90% of your average &lt;em&gt;local variable use cases&lt;/em&gt;, this default setting will either be OK or will just make no difference, and for the remaining ones, you&amp;#39;d use a!refreshVariable().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73889?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:07:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:25d4a3da-d7fd-4189-9d61-bd6c6ea7d307</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;load():&amp;nbsp; Variables in here only evaluated once when the form first loads.&amp;nbsp; By &amp;quot;evaluated&amp;quot; we mean run the code that comes after the variable definition.&amp;nbsp; Since the code is only ever run once, it means we can save values in these local variables that won&amp;#39;t immediately get overwritten.&amp;nbsp; So you&amp;#39;re actually required to use load() to make a variable that can be saved to.&lt;/p&gt;
&lt;p&gt;with():&amp;nbsp; Variables in here get reevaluated absolutely every time the user does anything with the form at all.&amp;nbsp; This allows for dynamic content, or things that refresh on a button click, for instance.&amp;nbsp; You don&amp;#39;t even need to configure the button to really do anything.&amp;nbsp; It just causes the with variables to be reevaluated.&amp;nbsp; If you define an empty with() variable, it gets re-emptied every time the user clicks or types anything, so nothing can be saved there.&lt;/p&gt;
&lt;p&gt;a!localVariables() fully replaces load and with.&amp;nbsp; The reason load and with aren&amp;#39;t relics yet is because essentially every application ever uses only those.&amp;nbsp; But load() and with() are now essentially tech debt, but tech debt that EVERYONE still has, pretty much.&lt;/p&gt;
&lt;p&gt;Each of your&amp;nbsp;variables inside a!localVariables() should be defined with it&amp;#39;s own a!refreshVariable function.&amp;nbsp; That function takes 2 parameters, where you define what the variable is, and define when that gets reevaluated.&amp;nbsp; Now you have not only the option of &amp;quot;never&amp;quot; and &amp;quot;any time the user does anything&amp;quot;, but also things like &amp;quot;every 30 seconds&amp;quot; or &amp;quot;when this variable changes&amp;quot; or &amp;quot;when some other variable changes&amp;quot;.&amp;nbsp; You should use this, because now you only have to make your with() variables update when it MATTERS whether they update or not.&amp;nbsp; But you can only do that by porting them over to a!localVariables and defining them with the proper a!refreshVariable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73888?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 13:01:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0df1a31c-9996-4d4e-8cc1-0c4f5039505b</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Wait, are you saying that couldn&amp;#39;t be done with &lt;em&gt;a!localVariables()&lt;/em&gt;?&amp;nbsp; Why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73887?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 12:54:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:82b17313-696f-4f82-83e5-62d22d51cc2c</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt; interesting position...I&amp;#39;d be interested in how you&amp;#39;d implement a nested a!forEach() where the inner loop requires a value from each outer loop. Obviously one option would be to write a rule that passed the entire fv!item, from which you&amp;#39;d extract the outer value and all the inner values...but if you wanted to do this without such a helper rule, you could use a with() to define a local!variable&amp;nbsp;that you could set (and re-set) for each outer loop and that is now made available to the inner loop.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73885?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 12:39:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3caf5431-e080-447f-af7f-48f2cf2a5122</guid><dc:creator>ST07</dc:creator><description>&lt;p&gt;This doesnt&amp;#39; have any info on a!localvariable function . I need to find difference between load and a!localvariable function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73884?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 12:32:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8d3d3057-b10a-4a3e-bbc0-5285e330c41a</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;&lt;em&gt;a!localVariables()&lt;/em&gt; &lt;a href="https://docs.appian.com/suite/help/19.2/Updating_Expressions_to_Use_a_localVariables.html"&gt;completely replaces&lt;/a&gt; load() and with().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Difference in load() with () and other functions</title><link>https://community.appian.com/thread/73883?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 12:20:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:88144f0e-58b2-480f-9336-4bc4bf10e0ba</guid><dc:creator>juergeng393</dc:creator><description>&lt;p&gt;Hi ST07&lt;/p&gt;
&lt;p&gt;you can find the explanation here:&amp;nbsp;&lt;a href="/discussions/f/user-interface/11603/load-and-with-function-difference"&gt;https://community.appian.com/discussions/f/user-interface/11603/load-and-with-function-difference&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>