How to set environmental variables and call it from adaptive form? | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Andrei_Dantsou
Andrei_DantsouAccepted solution
Level 3
Aug 25, 2020 10:32 AM UTC

Hello @mohamedn4455443 ,

If your goal is to use the values in your code you can use environment specific OSGI configurations https://docs.adobe.com/content/help/en/experience-manager-cloud-service/implementing/deploying/overview.html#runmodes

If you need to set up the url for referencing your site at different environments, it should be done at Dispatcher level https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/configuring/dispatcher-domains.html#create-dispatcher-farms-for-virtual-hosts

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.

Regards

 

 

if the Run Modes were set up accordingly at your environments, e.g. development, production, etc. (https://docs.adobe.com/content/help/en/experience-manager-64/deploying/configuring/configure-runmode...), 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 https://sling.apache.org/documentation/bundles/sling-settings-org-apache-sling-settings.html
The example of getting Run Modes in Sightly https://gist.github.com/gabrielwalt/278f8cee870aac7ec619

See: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-forms/getting-current-aem-run-mode-in-adaptive-form/qaq-p/320292

 

9 replies

Nikhil-Kumar
New Participant
Aug 25, 2020 3:53 PM UTC

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

   @Reference
   private static SlingSettingsService slingSettingsService;


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



Thanks,
Nikhil

Translate
mohamedn4455443
Level 3
Aug 25, 2020 4:00 PM UTC
no option to get configuration variable from adaptive form direct without maven project ?
Translate
Andrei_Dantsou
Andrei_DantsouAccepted solution
Level 3
Aug 25, 2020 10:32 AM UTC

Hello @mohamedn4455443 ,

If your goal is to use the values in your code you can use environment specific OSGI configurations https://docs.adobe.com/content/help/en/experience-manager-cloud-service/implementing/deploying/overview.html#runmodes

If you need to set up the url for referencing your site at different environments, it should be done at Dispatcher level https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/configuring/dispatcher-domains.html#create-dispatcher-farms-for-virtual-hosts

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.

Regards

 

 

if the Run Modes were set up accordingly at your environments, e.g. development, production, etc. (https://docs.adobe.com/content/help/en/experience-manager-64/deploying/configuring/configure-runmode...), 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 https://sling.apache.org/documentation/bundles/sling-settings-org-apache-sling-settings.html
The example of getting Run Modes in Sightly https://gist.github.com/gabrielwalt/278f8cee870aac7ec619

See: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-forms/getting-current-aem-run-mode-in-adaptive-form/qaq-p/320292

 

Translate
mohamedn4455443
Level 3
Aug 25, 2020 10:45 AM UTC
i just want variables such as webservice in production= x , webservice in test or development=y or in development form title = development and in production title = production automatic change based on system(development or production)
Translate