Global variables for all my Apps

Hi all,


I need to store 3 TEXT (FIXED) VARIABLES to use in ALL my WebApps (actually I have 35 of them).


Wich is the best / fastest way to do that ?


Sorry for my silly question.


Thanks !


LUCA

Hi Luca,

I would recommend for you to store those variables in a parametrization table.

Basically, you should create a table with those values and keys to obtain them. Place this table in a module server side that is shared between all of your applications. Or create a lib module (call it SharedData_Lib for example) to store this information.


Kind regards,

Rui Barradas

Thank you Rui for your answer ...


so, if I understand correctly, I can build a new application with a "blank" module type and create a single public table to store the informations I need ?


I tried the Site Properties, but they are not "shared" through all my WebApps ... I see them just in the App I created them ...

yes,

you don't even need blank, you can go as small as a service application, with a service module in it.


And just to offer an alternative to a table, you could still define your global variables as site properties if you like that better, just create a server or service action in your service module giving back the site property.

And reuse that action in all your applications.


Dorine

Solution

Hi again Luca,


"I tried the Site Properties, but they are not "shared" through all my WebApps ... I see them just in the App I created them..."

Site Properties are just for the module where you create them. You can't share site properties between modules, even if they are inside the same application.


"so, if I understand correctly, I can build a new application with a "blank" module type and create a single public table to store the informations I need?"

Exactly. You should create a "blank" module with a public table to store these variables. This module should work as a Library and it should be shared among your different applications. After, you can expose some actions in this module as well to retrieve the values that you want.


Kind regards,

Rui Barradas

Solution

Dorine, thanks for your answer ...


I tried to use the "Site Properties" ... but I'm able to see them just in the App I create them: I tried to use the Multi-Tenant True / False but nothing changed.


How to define them "public" in the way I can share them throug all my apps ?

Thanks Rui ... not it's perfectly clear !

Luca De Mori wrote:

Dorine, thanks for your answer ...


I tried to use the "Site Properties" ... but I'm able to see them just in the App I create them: I tried to use the Multi-Tenant True / False but nothing changed.


How to define them "public" in the way I can share them throug all my apps ?

by adding a server action in the same module your site property is in, with just one assign statement setting out parameter to site property.  Make that server action public, and maybe function too.  And then use that action everywhere you need the variable.


Hi Luca,

Actually, you can share site properties between modules through public server actions or service actions, but it still a bad idea to use them as global variables since you would invalidate the module's cache each time their values are changed.

Eduardo Jauch gives a pretty detailed explanation in this post.

Hope this helps!

Regards,

Nordin

Hi Luca,

What Dorine said was: you can have the library module as well, but instead of the table to store the information, you can store them in site properties and expose public actions in that module to retrieve these values stored in the site properties. However, like Nordin said, this is not a good call because everytime you change a value, you will invalidate the application's cache. In my opinion, you should keep with the table.


Kind regards,

Rui Barradas

Yes,

absolutely agree, for stuff that changes often, go with a table.  I based my answer on the 'FIXED' in the question.

Maybe something like a company legal name

Hi All,

Well, if you're in P10 or in a Traditional Web App in P11, you can use session variables.

Create an empty service module, create the session variables there and then create public actions to get and set the values.

Note that you should only use session variables for small objects, if you're going to need to save something like a string with 1000 characters, use a table instead.

If you're in a reactive web app in P11, using a parametrization table.