Mainatining state using local variable

Maintaining state  while navigation across the screens using local variable. is it possible if so please suggest .

https://softwareengineering.stackexchange.com/questions/346867/how-to-keep-applications-stateless

Local variable is not a proper one as its name implies - "LOCAL" - which has a local scope and lifetime inside a block.


Local variable's scope is only limited to the action/screen they are on, which means that when navigating away from said screen, the variable values are cleared. Basically "it exists only within the block that it is declared in. Once that block ends, the variable is destroyed and its values lost".

If you want to store values while the user is in session, you should use "Session variables"

These variables will store the values while the user has his/her session active. The most common use for these variables are filters.

For instance, the user filters a table and selects a record from that table that will redirect him to the screen with the details of that record. If the user presses "Back" the filters will hold the values previously entered and the table will still be filtered. To achieve this simply bind the variables used in the inputs of the filters to these variables, which can be accessed using "Session.[variableName]"

Tiago Carmo wrote:

Local variable's scope is only limited to the action/screen they are on, which means that when navigating away from said screen, the variable values are cleared. Basically "it exists only within the block that it is declared in. Once that block ends, the variable is destroyed and its values lost".

If you want to store values while the user is in session, you should use "Session variables"

These variables will store the values while the user has his/her session active. The most common use for these variables are filters.

For instance, the user filters a table and selects a record from that table that will redirect him to the screen with the details of that record. If the user presses "Back" the filters will hold the values previously entered and the table will still be filtered. To achieve this simply bind the variables used in the inputs of the filters to these variables, which can be accessed using "Session.[variableName]"

Hi Carmo,

We are using session variables for control/calendar of silk ui but the values are getting refreshed on press of back button in the browser but for all other input fields than calendar it is not getting refreshed.we are using outsystem version 10.

Thanks,

Ronan T



Ronan T wrote:

Tiago Carmo wrote:

Local variable's scope is only limited to the action/screen they are on, which means that when navigating away from said screen, the variable values are cleared. Basically "it exists only within the block that it is declared in. Once that block ends, the variable is destroyed and its values lost".

If you want to store values while the user is in session, you should use "Session variables"

These variables will store the values while the user has his/her session active. The most common use for these variables are filters.

For instance, the user filters a table and selects a record from that table that will redirect him to the screen with the details of that record. If the user presses "Back" the filters will hold the values previously entered and the table will still be filtered. To achieve this simply bind the variables used in the inputs of the filters to these variables, which can be accessed using "Session.[variableName]"

Hi Carmo,

We are using session variables for control/calendar of silk ui but the values are getting refreshed on press of back button in the browser but for all other input fields than calendar it is not getting refreshed.we are using outsystem version 10.

Thanks,

Ronan T



Browsers handle the "back" button strangely, and depending on how a value got put into something, they will keep whatever value was there before the page moved forwards, or they will reset it. Remember, "back" USUALLY does not actually reload the page from server, it reloads the page from the browser cache.

Session Variables are almost always the wrong way to handle something like this anyways, because it becomes complete chaos when the user has the same page open twice in separate tabs/windows. I have mostly eliminated them from my applications, other than *sometimes* storing search variables. In general, the more you test and the deeper you test, the more you see problems caused by using session variables. Not that the implementation itself is wrong, but because they cause logical difficulties.

J.Ja