AEM xpath query with lastreplicated and custom date property | Community
Skip to main content
srinivas_chann1
Level 7
September 10, 2022
Solved

AEM xpath query with lastreplicated and custom date property

  • September 10, 2022
  • 1 reply
  • 1958 views

Hello,

 

I will need a xpath query that will perform

Check in damasset if under jcr:content the below properties , and may have customDateProperty  

 

1>cq:lastReplicated  is today

2>cq:lastReplicationAction is Activate

3>customDateProperty  -> check if exists under jcr:content , if exists then check the timestamp if cq:lastReplicated timestamp and date is greater then customDateProperty

 

Could you please provide inputs on this

 

Regards,

Srinivas

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 Sachin_Arora_

In code you can write a check if customProperty exist or not and based on that you can create different query.

I gave today's date in daterange.lowerbound you can update dynamically in the code. You can also explore relativedaterange if above query does not fit for your requirement.

https://hashimkhan.in/2015/12/02/query-builder/

 

1 reply

Sachin_Arora_
Community Advisor
Community Advisor
September 10, 2022

You can use dateComparison Predicate to compare 2 JCR Date. 

Link : https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/query-builder/querybuilder-predicate-reference.html?lang=en#datecomparison

 

This query should help in your case. You can replace cq:lastModified with customProperty in line 3

path=/content/dam/we-retail
dateComparison.property1=cq:lastReplicated
dateComparison.property2=cq:lastModified
dateComparison.operation=greater
property=cq:lastReplicationAction
property.value=Activate
daterange.property=cq:lastReplicated
daterange.lowerBound=2022-09-10T00:00:00.000+05:30
daterange.lowerOperation=>
srinivas_chann1
Level 7
September 10, 2022

@sachin_arora_ 

Hello, 

Thanks for the input. The query gave me goods insight as what could be done.

 

I still have one problem , if you could help me on it  based on the previous xpath query 

 

3>  customProperty if we replace with  cq:lastModified .

 

3a>We need to check if the customProperty exists , only then do the 

if cq:lastReplicated timestamp and date is greater then customDateProperty

-> As the customProperty  may not be present always on  this nodes

3.b> Also check for the below

 a>cq:lastReplicated  is today

b>cq:lastReplicationAction is Activate

 

 

4> In case we don't have the customProperty  then , it must  still give the results based on

 

 a>cq:lastReplicated  is today

b>cq:lastReplicationAction is Activate

 

Thanks,

Srinivas

 

Sachin_Arora_
Community Advisor
Sachin_Arora_Community AdvisorAccepted solution
Community Advisor
September 12, 2022

In code you can write a check if customProperty exist or not and based on that you can create different query.

I gave today's date in daterange.lowerbound you can update dynamically in the code. You can also explore relativedaterange if above query does not fit for your requirement.

https://hashimkhan.in/2015/12/02/query-builder/