Expand my Community achievements bar.

Delete DAM asset workflow

Avatar

Level 3

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?

14 Replies

Avatar

Employee Advisor

To answer your questions:

1. Try to find the query that is getting triggered for calculating references and use the explain query[3] 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[2] and use the AssetReferenceSearch[1] to calculate the references.

[1] AssetReferenceSearch ("The Adobe AEM Quickstart and Web Application.")

[2] Adobe Experience Manager Help | Creating custom AEM workflow steps that send email messages

[3] http://<host>:<port>/libs/granite/operations/content/diagnosistools/queryPerformance.html

Avatar

Level 3

Thanks Jaideep.

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?

Avatar

Level 3

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:

AssetValidationWorkflow

Avatar

Level 3

Simple workflow model to trigger the above Asset Validation is available here

Avatar

Level 3

Thanks, dvnSudheer

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.

Avatar

Level 3

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

Clientlibs directory

New Button Creation

Servlet

Workflow Model

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.

Avatar

Level 3

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?

smacdonald2008Arun Patidar

Avatar

Community Advisor

Hi,

You can create your own custom renderer to show/hide buttons based on path.

for example

AEM - Granite Custom Render Conditions using Servlet



Arun Patidar

Avatar

Level 3

Thanks Arun Patidar

I got the issue but not its fix. Actually, When I select a folder under the allowed path, it works first time and shows the button. and then it caches the value. So now, next time "not allowed" folder is selected, it is still showing button.

After refreshing the screen, it removes the cache and doesn't show button on "not allowed" folder. Then If I selected allowed path, it does not show button. So it requires to refresh every time.

I have tried your solution too but it is behaving the same way. I have tried having JSP too with adding no-cache in response but in vain.

I have tried Granite expressions, acs-common path, Reuqestinfo. Suffix and other suggested solutions on the net. but it is behaving the same.

So do we have any way that it will always get the value from servlet/JSP/rendering conditions without the need of refreshing the screen?

dvnSudheersmacdonald2008JaideepBrar

Avatar

Community Advisor

Hi,

The renders work only with page load.

If you need to implement something on select then you need to hide button using css and show/hide based on select/click event using jquery or javascript.

Example

Asset Collections Action Condition



Arun Patidar

Avatar

Level 3

Arun Patidar

thanks for your suggestion. but it seems that this logic is also not working. Flag gets updated only after refresh.

Avatar

Level 3

Arun PatidardvnSudheer

could you please let me know what could get wrong in this?

The refresh issue is still there and is not calling the JS mentioned in other thread: Asset Collections Action Condition