Not able to get correct result for published page as the draft pages are also having 'cq:lastReplicated' & 'cq:lastReplicationAction' properties from the templates | Community
Skip to main content
Level 2
December 14, 2021
Solved

Not able to get correct result for published page as the draft pages are also having 'cq:lastReplicated' & 'cq:lastReplicationAction' properties from the templates

  • December 14, 2021
  • 1 reply
  • 1478 views

Hi All,

 

I am trying to get the result of pages which are published in author instance. But I am not able to get the correct results as newly created pages from a published template is taking 'cq:lastReplicated' & 'cq:lastReplicationAction' properties from the template. So even if we are not publishing that newly created page, we are seeing these properties being added in the jcr:content from the template as the template was already published. 

 

Can anyone please help on this how we can remove these properties from newly created pages/ draft pages which hasn't been published?

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

Please do not read these properties directly, as technically they are an implementation detail. 

Rather do something like this:

ReplicationStatus status = page.adaptTo(ReplicationStatus.class);
if (status.getAvailableAgents("preview")) {
  // status available for preview
  boolean canBeViewedOnPreview = status.getStatusForAgent("preview").isActivated();
}

(https://javadoc.io/doc/com.adobe.aem/aem-sdk-api/latest/com/day/cq/replication/ReplicationStatus.html)

 

 

1 reply

Pawan-Gupta
Level 8
December 14, 2021

Hello,

 

Can you check if one of below property helps you there??

 

cq:lastReplicated_publish
cq:lastReplicatedBy_publish

 

Thanks!!

Level 2
December 15, 2021

hi Pawan,

 

Thanks for the suggestion but I am not seeing these properties in the page jcr:content. I am generating the result in author and not from the publish environment. I have to get the list of pages which are activated/published from the authors. So while doing so, I am getting those pages also in the list which are newly created and not activated/published. This is because its taking the lastreplicated property from the template used for creating the page.

 

Thanks & Regards,

Abhishek

Pawan-Gupta
Level 8
December 15, 2021

Hi Abhishek,

 

I think you answer the question. if those properties are not available then you can use that as condition to know the pages which are not published because when you publish pages, these two properties should populate corresponding values.

 

I hope you understand it now.

 

Thanks!!