Hi team,
May I know how to identify preview environment programmatically in aem as a. Cloud service.
Views
Replies
Total Likes
Hi Kroyal
Not sure if you want to identify it in the Java Model or in the view, below you can find both options.
Java Sling Model
You can inject SlingHttpServletRequest in your model and get the WCMMode out of it like this
View
In the view the wcmmode is globally available, so it's enough to add following check
@kroyal12Sorry, misread the question...
I am affraid that it's not that easy...
I don't think there is a way to do that out-of-the-box, what you could do it create an OSGi Configuration with a Service which is using a environment variable that is configured through Cloud Manager on the preview environments.
For example, you can define a variable IS_PREVIEW_ENV, and use that variable in your OSGi Config.
Documentation for configuring a environment variable through Cloud Manager you can find here.
Example on how to use those environment variables in your OSGi Configuration you can find here.
Sure, not the answer you hoped for, but it's the best I could do... Maybe someone else has a beter solution for you!
Greetings
Rik
@kroyal12 Are you talking about finding environment runmode in cloud? Or just WCMMODE = Preview ?
https://www.theaemmaven.com/post/the-slingsettingsservice-run-modes-in-aemaacs
Talking about environment
@kroyal12 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies