Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

In asset metadata modifed by is not getting updated with correct user id

Avatar

Level 1

In the asset metadata, I have a custom tab with a custom field called "Modified By." I have a schema named "myproject," where I added this custom tab, labeled "File Information," and created a field called "Modified By." This field is mapped to a custom property, "xmp:modified-by"
. The "Modified By" field is non-editable, as its value is set from the backend whenever anyone updates any field in the asset's metadata (e.g., the title).
When a metadata field is updated, a custom workflow called "Update Metadata" is triggered by a launcher. Within this workflow, there is a process step called "Update CQ Name," where we update/add the custom property "xmp:modified-by" into asset's metadata node.
We fetch the value of the jcr:lastModifiedBy property from the asset's jcr:content node and save it in the asset's metadata node under the property xmp:modified-by.
However, the xmp:modified-by property is getting updated with an older value of jcr:lastModifiedBy. From my understanding, the workflow is triggered before the jcr:lastModifiedBy property is updated with the latest user who made the changes. I have checked the timing of jcr:lastModified and reviewed the logs to see when the workflow code is executed.
The workflow is getting completed successfully. There is no error in the logs.

I have used varunk user id for modification in asset properties.

This is the Screenshot before updating asset properties

varunkiroriwal_0-1725206558148.png

 

This is the Screenshot after updating asset properties

varunkiroriwal_1-1725206644806.png

 

screenshot of xmp:modifed-by property in the metadata node after updating asset properties

varunkiroriwal_3-1725207372107.png

 

screenshot of log file with workflow process start time

varunkiroriwal_4-1725207432942.png

 

you can notice workflow process step started at :

01.09.2024 20:30:46.390

 and value of jcr:lastModifed property in the jcr:content node is(in 2nd screenshot):

2024-09-01 T 20:30:46.505+05:30 

 

screenshot of the launcher properties

varunkiroriwal_5-1725208062825.png


why it is taking the previous value of jcr:lastModifiedBy and why workflow is triggered before latest value get saved in jcr:lastModifiedBy?

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I think using Sling Event Handler is much more apt way to achieve your use case.
Attach a sling event handler/listener on Asset Modification and carry out the Asset Metadata updation in that osgi component.

Here is a sample event handler for Asset Modification:
Event Handler for Asset's modification (edit, copy ..etc)


Check above blog out.
Or in general if you want to check Sling event handlers and listeners : 
https://medium.com/@toimrank/aem-handler-and-listener-12b6c8b5a3d3

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

I think using Sling Event Handler is much more apt way to achieve your use case.
Attach a sling event handler/listener on Asset Modification and carry out the Asset Metadata updation in that osgi component.

Here is a sample event handler for Asset Modification:
Event Handler for Asset's modification (edit, copy ..etc)


Check above blog out.
Or in general if you want to check Sling event handlers and listeners : 
https://medium.com/@toimrank/aem-handler-and-listener-12b6c8b5a3d3