Need source code how we are updating jcr:lastModifiedBy when we update content fragment | Community
Skip to main content
Level 2
January 14, 2025
Question

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

  • January 14, 2025
  • 1 reply
  • 572 views

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

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 14, 2025

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.html#3.7.11.8%20mix:lastModified 

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

 

 

Hope this helps

Esteban Bustamante
Level 2
January 14, 2025

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