does a!localVariables() refresh local variables by default?

My team is using Appian 19.2 and since they now have a!localVariables() as a replacement for load(0 and with(), we've been using it explicitly. However I noticed that if I have local variables that query data inside the local variables definition, it queries the data every time something changes inside the form.

Let's assume I have the following code snippet

a!localVariables(

local!id,
local!data = rule!getMyData(id: local!id),

{...rest of code here...}

)

With the above code, the query gets triggered every time local!id changes without having to use the a!refreshVariable() function. This is basically the same behavior we had with with() function, but something I did not expect.

Now if I have the following:

a!localVariables(
local!data = rule!getMyData(),

{...rest of code here...}

)

Now I'm just querying the database and pulling all the data since I don't need to query based on conditions. Is this also querying the database everytime something changes on the form. I can't tell since the data is the same every time and there is no indication as to when the data was last queried. 

Where I'm going with this is, do I need to use the a!refreshVariable() function with queries to avoid the overhead of querying the database every time. The documentation for 19.2 mentions the refresh function in order to update variables, but it does not mention what happens to locals that don't have it. In that case, does it behave like a load() or a with(). Is there a way to tell?


  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    To confirm, variables defined in a!localVariables(), but without using a!refreshVariable(), will be defined with all the default settings for a!refreshVariable() - this includes the parameter of "refreshOnReferencedVarChange" defaulting to TRUE.  When changing over load() calls to a!localVariables(), this needs to be taken into account - mainly, if defining a local variable to hold the *original* value of some previously-defined value on the form, one would need to set refreshOnReferencedVarChange to FALSE.  All in all, though, the new system should make most standard use cases easier (and it also makes some previously impossible ones possible).

Reply
  • +1
    Certified Lead Developer

    To confirm, variables defined in a!localVariables(), but without using a!refreshVariable(), will be defined with all the default settings for a!refreshVariable() - this includes the parameter of "refreshOnReferencedVarChange" defaulting to TRUE.  When changing over load() calls to a!localVariables(), this needs to be taken into account - mainly, if defining a local variable to hold the *original* value of some previously-defined value on the form, one would need to set refreshOnReferencedVarChange to FALSE.  All in all, though, the new system should make most standard use cases easier (and it also makes some previously impossible ones possible).

Children