29
Views
10
Comments
Solved
Iterate through client variables
Question

Is it possible to iterate through my client variables to display their values on a screen? For example, the screen would display:

Client.City = Lisbon ("Lisbon" is is the value of Client.City)

Client.Country = Portugal ("Portugal" is is the value of Client.Country)


I'd like to do this for testing purposes. 

Rank: #173
Solution

Hi,

Component to list local storage and Client Variables:

https://www.outsystems.com/forge/component-overview/9588/local-storage-js

Regards.

mvp_badge
MVP
Rank: #78

Hi Michael,

You can use the Expression widget to reference the client variable value within the Screen canvas as shown below.


Kind regards,

Benjith Sam

Rank: #2526

Thank you Benjith, that is what I have been doing. However I'd like to loop through all of the client variable names rather than hardcoding them in an expression widget. Something like this pseudo code:

for each client.variables

       client.variable.name + "=" + cleint.variable.value 

next 


Rank: #373

Hi, friend.

I don't think it's possible to iterate throught them. You can do that manually using a struture type list and append the values to it. Or even make it public. 

The following documentation explain how to do that and handle those variables for some porpuses. Let me know if it's helpful.

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Share_a_Client_Variable_between_apps

Rank: #477

I would probably just create a test structure of type text.   Then create a list of that structure type and then on initialize add all of the client variable values to that structure list.   Then you can just display the list and get all of the values.

Rank: #1977

HI Michael,

Client Variables are stored in local storage in browser and i think outsystems doesnt have any function to get all the list of client variables but you can get them by javascript  "localStorage"  variable . and outsystems append some text before the client variable for example $OS_Users+ModuleName$ClientVars+Client Variable name . You need to extract the client variable name from the localstorage key  

Best regards

Devendra






Rank: #173

Hi Michael,

You can get your Client Variable with JavaScript, follow this example:


for ( var i = 0, len = localStorage.length; i < len; ++i){

   $parameters.LocalStorage = $parameters.LocalStorage +'^' +   localStorage.key(i) + '=' + localStorage.getItem( localStorage.key(i) );

}




Regards.



Rank: #173
Solution

Hi,

Component to list local storage and Client Variables:

https://www.outsystems.com/forge/component-overview/9588/local-storage-js

Regards.

Rank: #2526

Thank you Agno - this component demo works very nice. Cheers!