Service or event that I can listen so I can check if the publish action will be for preview or publish? | Community
Skip to main content
Level 3
October 31, 2024
Solved

Service or event that I can listen so I can check if the publish action will be for preview or publish?

  • October 31, 2024
  • 3 replies
  • 747 views

Hi again, 
Would like to ask if there is any services or events that I can listen from the Preprocessor to determine if the replication action is for Preview or Publish.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

arunpatidar
Community Advisor
Community Advisor
October 31, 2024

Hi @lyonmartin 
I have not tried that but can you check if you can use below get replicationType/agentType details from 

https://medium.com/@bsaravanaprakash/how-to-subscribe-to-sling-distribution-event-on-aemaacs-cac2fecbc05a 

Arun Patidar
Tethich
Community Advisor
Community Advisor
October 31, 2024

Hi @lyonmartin 
Publishing some content for preview purpose is done via Manage Publication UI, where you can choose if you content is either for Publish or Preview. Maybe you can start there, open browser Inspect and try to figure out how AEM handles it. Which request is made to AEM server, how AEM knows your selection to decide that it need to do the work for preview or publish and so on. This may put you on a path to know what to think of to out in your code base, to have a similar logic.
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/sites/authoring/sites-console/previewing-content

 

Once you have a fulcrum, then you can thing of a way to inject your logic in the preprocessing phase. Some examples and useful comments here:
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/override-replication-behavior/m-p/597320
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/disable-or-override-ootb-replication-preprocessor/m-p/377095

 

Update: @mukeshyadav_ suggestion sounds really to the point also