Reactive web - Getting values from localstorage and assigning to variable

I have a Reactive webapp that store something in a localstorage (Client variable)

Using chrome to check the localstorage, the Variable in localstorage looks like this:

$OS_Users$MyApp$ClientVars$MyVariable


Now how can i use Javascript to retrieve the variable and assign it to an Outsystems Reactive web app variable?


I'm thinking something along the lines of:

//retrieve localstorage and assign it to 'a'

var a = localStorage.getItem('$OS_Users$TestReact1$ClientVars$asp_TempBranchID')

//Now i'm stuck how to assign var a to outsystems variable.


Hi Kelvin,


is there a reason why you want to use javascript to do this?  Why not just have an assign statement in your OS flow assigning the value of the client variable to a local variable of the screen you need it in ? 


Dorine

Hi Kelvin,

Check this plugin: https://www.outsystems.com/forge/component-overview/6978/local-storage-rwa 

I think that can help you. 


Best regards

Dorine Boudry wrote:

Hi Kelvin,


is there a reason why you want to use javascript to do this?  Why not just have an assign statement in your OS flow assigning the value of the client variable to a local variable of the screen you need it in ? 


Dorine

Hello,


I'm doing this as we need something that is being stored even when user logs out or navigate to other page.

Then whenever they return to the login page, I will use the encrypted value store in localstorage to load some data for the user.


Hi Kevin,

what i meant was, why use javascript.  They are available for use as clientVariable inside OS flows.