Expand my Community achievements bar.

Need source code how we are updating jcr:lastModifiedBy when we update content fragment

Avatar

Level 2

Hi,


I want to understand how jcr:lastModifiedBy and jcr:lastModifiedDate getting updated when we update the contentfragment. Need source code how we are updating jcr:lastModifiedBy when we update content fragment. 

Please help me on the same with the source code

 

Thanks & Regards,

Kalyan

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

Hi,

 

These properties are automatically created and managed by JCR. In general, most nodes will automatically add or update these properties when there are changes to the node[1]. Since these are protected properties, it is not recommended to update them programmatically. If you need to track an updateInformationDate based on business requirements, the best approach is to create a custom property and update it as needed. However, if you still wish to update these properties directly, the following approach should work:

Node node = session.getNode(path)
node.setProperty("jcr:lastModified", Calendar.getInstance()); 
node.setProperty("jcr:lastModifiedBy", "esteban"); 
session.save();

 

You can learn more here: 

[1] https://developer.adobe.com/experience-manager/reference-materials/spec/jcr/2.0/3_Repository_Model.h... 

https://stackoverflow.com/questions/74526184/lastmodified-and-lastmodifiedby-fields-in-aem-nodes 

 

 

Hope this helps



Esteban Bustamante

Hi @EstebanBustamante ,

 

Thank you for reply. These properties are automatically created and managed by JCR. I want to understand the flow how it is happening using oob. Can you please help me how it is getting created using the code(I mean oob source code)

 

Thanks & Regards,

Kalyan