We have a requirement for workflow for approval on the deletion of a DAM asset.
The requirements are :
The author should request for deletion of an asset.
Workflow should check
1. if Asset is not published
2. If the asset is referenced in any page
If both conditions are met, the "Librarian" group should able to receive the workflow request.
Once the Librarian approves the workflow, it should delete the asset, mail should be triggered to the initiator and super users
Once the Librarian rejects the workflow, it should not delete the asset, mail should be triggered to the initiator and super users
Workflow has been created with Dynamic Participant step for verification.
Launcher configuration has been made to initiate the workflow when Node is removed on DAM: asset node.
But the challenges are :
1. Finding assets references in 2000 pages in query is slowing performance.
2. When Author clicks on the delete button, it triggers workflow but also deletes the asset same time. So even if the workflow is rejected, assets are deleted.
So I need few inputs :
1. What is best way to check references without impacting performance?
2. Do we need to hide delete button ? and show "Request for deletion" for DAM assets ? if yes, how we can do that?
To answer your questions:
1. Try to find the query that is getting triggered for calculating references and use the explain query tool to find the index that query is using. Then try to optimize the index Or create a new index if its a traversal query.
2. Delete option is read from "/libs/dam/gui/content/assets/jcr:content/actions/selection/delete" , So, you can use sling resource merger(hide:resource) to hide the delete tab and add a new tab for request for deletion.
You can also, create a custom workflow step and use the AssetReferenceSearch to calculate the references.
1. I am able to hide delete button using sling merger but it is not showing new tab/button for "Request for Deletion".
2. How to call a workflow from this new button?
3. "backspace" is a shortcut for direct delete, will the new button need to override "backspace" shortcut key too?
DAM update asset workflow will not be triggered for Asset deletion.
One way is to write a simple workflow model. Create a process step which will check for the asset references or activation status.
If the asset is published or have any references you can send an email to the required users (ideally who started the workflow and any other admin user) and complete the workflow.
If it is not published or don't have any references, you can use the API to delete the asset and complete the workflow.
So, whenever an author would like to delete the asset, request him to trigger the custom workflow for the asset which will take care of the requirement.
Sample Workflow process can be found here:
I have created a workflow model by creating some dynamic steps and verify the "replicate" status of payload in dynamic participant steps.
The issue is: When I am triggering this workflow from the launcher, the asset is getting deleted even before completion of the workflow.
So as per suggestions above, I have hidden the "delete" button and trying to a new button "Request for deletion" and on this button, I am trying to initiate my workflow. I am not able to find the point or way to trigger the workflow from the button.
pankajkdhingra, Once you have clicked on delete there is no way to recover, so launches are not the right option. It only triggers when the delete event happened.
The other approach which you are looking at is a separate button for "Request for deletion"
For this, you have to create a clientlibs in which you can create a click action of your button. I have created a sample button and triggered the servlet. It also supports to send the asset paths if multiple are selected.
You can find the example in my github repository GitHub - sudheerdvn/aem-flash
The servlet reads the asset paths, you can add the required logic based on your requirement in the above servlet.
If you would like to start a different workflow, you can find the sample to start the workflow in the same servlet.
Thanks a lot, Sudheer. With your help and few customization, i was able to create customized workflow for deletion of DAM assets in the workflow.
I am stuck at one more point: "Request to delete" button should appear on only "/content/dam/ABC" path.
I have tried Granite expressions, acs-common path, Reuqestinfo.Suffix and other suggested solutions on net. But Button is either appearing on all paths or none.
could you please suggest the correct way to do it?