In asset metadata modifed by is not getting updated with correct user id | Community
Skip to main content
September 1, 2024
Solved

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

  • September 1, 2024
  • 1 reply
  • 596 views

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

 

This is the Screenshot after updating asset properties

 

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

 

screenshot of log file with workflow process start time

 

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


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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by pulkitvashisth

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

 

1 reply

pulkitvashisth
Community Advisor
pulkitvashisthCommunity AdvisorAccepted solution
Community Advisor
September 1, 2024

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