Evaluation of local variables...

Hi,

why is it that in the following example (from tutorial 103) the query rule is evaluated on first load and the other local!Variables seem to be evaluated whenever there is a change?

a!localVariables(
  local!locationsList: rule!ONT_INT_getAllAddresses(
    adressID: null
  ),
  local!newAddress: 'type!{urn:com:appian:types:ONT_INT}address'(),
  local!showAddressBox: false,
  {
    a!sectionLayout(....

Later  the option List in the tutorial example  gets appended  with a newly entered address

a!buttonWidget(
              ...
                ),
                a!save(
                  target: local!locationsList,
                  value: append(
                    local!locationsList,
                    local!newAddress
                  )

My expectation was

a) the list gets appended

b) appian re-evaluates the variables in the form and

c)  the added element would be lost after the update of the value of the local variables, because the definition of : " local!locationsList: rule!ONT_INT_getAllAddresses( adressID: null ) in the first line would overwrite the latest change...

But it does not.

How does Appian now which variable to update and which not?

Thx and sorry for asking

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    To add to the prior answer - local variables declared without specific overrides (provided within a!refreshVariable()) are by default set to auto-refresh on (and ONLY on) "referenced variable" update, i.e. an update to any variable value used in its definition.

    To wit, your initial local!locationsList would not auto-refresh under any circumstances (since it doesn't refer to any external variables to determine its value), and therefore you can push manual changes to it externally (such as your append() operation) without worrying about those changes getting overwritten.

Reply
  • 0
    Certified Lead Developer

    To add to the prior answer - local variables declared without specific overrides (provided within a!refreshVariable()) are by default set to auto-refresh on (and ONLY on) "referenced variable" update, i.e. an update to any variable value used in its definition.

    To wit, your initial local!locationsList would not auto-refresh under any circumstances (since it doesn't refer to any external variables to determine its value), and therefore you can push manual changes to it externally (such as your append() operation) without worrying about those changes getting overwritten.

Children