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
Having the same issue right now.
The OSGI configuration of preview is the same as the one of publish. At least this document states:
A config.preview OSGi configuration folder cannot be declared in the same way a config.publish can be declared folder. Instead, the preview tier inherits its OSGi configuration from the publish tier's values.
So I guess the recommendation will not work.
@kroyal12 Did you find a solution?
Views
Replies
Total Likes
@mo76 I think you did not understand what @kroyal12 explained, you are not defining a runmode for "preview", you won't have something like "config.preview", instead, you are defining an Environment Variable which will change its value only in the preview environment, please read carefully here: https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/usi...
Hope this helps
@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