Skip to main content
Level 2
Jan 14, 2025 3:36 PM UTC
Question

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

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

2 replies

EstebanBustamante
Adobe Champion and Community Advisor
Adobe Champion and Community Advisor
Jan 14, 2025 8:53 PM UTC

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

Translate
Esteban Bustamante
Level 2
Jan 14, 2025 10:30 PM UTC

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

Translate