Hi Community,
I have a question on the use of the with() function on interfaces. More to do with how memory is managed when load and with is used. Say we have the following code
with( local!Variable1:rule!retrieveDataFrmCustomerTable(Filter1,Filter2),
)
What I expect it to so is when my page loads the output of the query retrieveDataFrmCustomerTable with 2 filters is stored in the Variable1. Now if i just call the variable2 in my code lets say 10 times, will APPIAN execute the "rule!retrieveDataFrmCustomerTable(Filter1,Filter2)" ten times or will it just keep playing with the initial data which was called when the with function was executed.
The reason i ask is to seek clarity on the fact whether the Variable1 is just a pointer to the retrieveDataFrmCustomerTable query and is called each time Variable1 is called which will make a call to the back end data base each time or since i have used Variable1 alongside with() the retrieveDataFrmCustomerTable query will be run just once and it will be kept in the memory for APPIAN to use.
Discussion posts and replies are publicly visible
From the documentation:
In interfaces, this function differs from the load() function because it recalculates the local variable values after interactions. This recalculation always happens, even if the interaction's updates could not have impacted the variable's value.
Just using local!variable1 in your code won't cause the query to be executed again. Instead, the query will be executed again any time that the user interacts with the interface.
local!variable1
Thanks Carlos. So basically what you are saying is that once the page is loaded the 1st time the data for the query gets loaded onto my local!variable1 in the cache memory, and then each time i am referencing this local variable the data is not fetched from the DB again but the data already available in the cache is used. Please correct me if i got it wrong here.