How to set environmental variables and call it from adaptive form?

Accepted Solutions (1)

Accepted Solutions (1)



Hello @mohamedn4455443 ,

If your goal is to use the values in your code you can use environment specific OSGI configurations

If you need to set up the url for referencing your site at different environments, it should be done at Dispatcher level

Alternatively, you can expose the necessary property at the page component level and set it up in the Page Properties of the root page at the specific environment.

The approaches may vary depending on your use cases.




if the Run Modes were set up accordingly at your environments, e.g. development, production, etc. (, you can get the current Run Mode at backend and it will contain the corresponding value, such as development or production. The example of getting the Run Modes in Java code
The example of getting Run Modes in Sightly



Answers (1)

Answers (1)




As mentioned by @Andrei_Dantsou , setup the OSGI configuration and use the following code in case of getting runmodes in model or component class:

   private static SlingSettingsService slingSettingsService;

slingSettingsService.getRunModes().contains("prod")    ---> For production
slingSettingsService.getRunModes().contains("dev")     ----> for development