Expand my Community achievements bar.

SOLVED

AEM xpath query with lastreplicated and custom date property

Avatar

Level 8

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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/

 

View solution in original post

3 Replies

Avatar

Community Advisor

You can use dateComparison Predicate to compare 2 JCR Date. 

Link : https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/query-builder/quer...

 

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=>

Avatar

Level 8

@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

 

Avatar

Correct answer by
Community Advisor

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/