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
Hello! I would recommend reading though this documentation page: https://docs.appian.com/suite/help/20.2/Local_Variables.html
Essentially, local variables values are set when the interface first loads. Variable values can either be updated by saving into them from a component or by setting a refresh configuration for the variables using a!refreshVariable (see that documentation page for more details and examples)
Hopefully that helps give a better picture of how local variables work!
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.
Why did you apologize for asking?
thx. that was informative reading, but not an easy matter to understand...
thx
because it is important to me to be polite and I know that answering newby questions is not always fun