227
Views
11
Comments
Solved
WEB Local Storage Javascript
Question

Dear All,


in a preparation of a WebScreen i can set a local-storage-variable you can find in the Chrome-developers-console with javaScript:


Does anyone know how to get a local-storage-variable? (Without using a hidden field on the screen)....


Thanks!

mvp_badge
MVP
Rank: #2
Solution

@Paulo,

Erm, yes, that's what I already said above ;)

mvp_badge
MVP
Rank: #2

Hi Jeroen,

What are you trying to achieve? Why are you using JavaScript at all?

Rank: #150

Hi Kilian,

i'm using an external plug-in which is completely based on javascript.
I can set the values/variables which are needed within this plugin, so that's OK.

While using the plugin (runtime) the local storage variables are changed and i need the new values for processing further in OutSystems........

That said, sometimes it can be handy to alter local (Outsystems) variables in a (screen-)action using javascript.
Last week i needed the acsii-value of a character. OutSystems doesn't have a build-in function for that, only the other-way-around. In JavaScript it's very easy.........

mvp_badge
MVP
Rank: #2

Well, when using JavaScript for Web Apps, keep the client-server model in mind. Any OutSystems code in Screen Actions (and Server Actions) runs on the server, so in order for them to have access to something you do in JavaScript, you need to pass it to the server, which must be done via things like hidden inputs.

Rank: #150

So I read on other posts :-(

The only thing I find very strange that I can set the variables, but I cannot get the same variables ?!?!

mvp_badge
MVP
Rank: #2

Hi Jeroen,

Not sure what you mean. Setting and getting the local variables can be done via JavaScript, which is executed client side. However, as soon as you want to use the local variables server side, you need to transfer them from the client to the server. Note this has very little to do with OutSystems specifically, but is a result of a client-server architecture.

Rank: #223

Hi Jeroen,

Yes, you can get the variables, using something like that:

Put Variable (As you use):

localStorage.setItem('_NSCaseId', nsId);

Get Variable:

localStorage.getItem('_NSCaseId');


Regards!

Rank: #223

Hi Jeroen,

If you have a variable in OutSystems, you cant assign a value from Javascript (in this case, from a local storage), because the variable in Outsystems are defined in the server side, and you try to assign a value from client side. 

Regards

mvp_badge
MVP
Rank: #2
Solution

@Paulo,

Erm, yes, that's what I already said above ;)

Rank: #150

I understand. Then I have to find a way to alter local variables, because in my case there isn't a build-in function which is useful.

Thanks all!