Customizing Detect Duplicate Result

Customizing Detect Duplicate Result

We have seen in the previous blog how we can detect any duplicate asset and the result contains a list of all the duplicate assets. Now if you have noticed when you click on the items in the list, it is not redirecting to the respective assets. So, if you want to know how you can achieve that follow this blog.

The duplicate detect dialog is as shown below. To summarize, here I am trying to upload def.jpg, but it’s duplicates already present in the dam so I am getting those assets list in the result. As you can see the result is non-clickable and cannot redirect to the corresponding images.





In order to achieve clickable result or if you want it to redirect you to those assets follow below steps.
  • First step is to find the script that is responsible to render this response. After debugging, I found that "/libs/dam/gui/coral/components/commons/fileupload/clientlibs/fileupload/js/fileupload.js" is responsible for rendering this dialog.
  • After finding the script, debug it to find code snippet used in this dialog.
    "_detectDuplicateAssets" function gets called if there exists any duplicate assets.
  • After finding correct function, modify corresponding element.
    If you analyse "_detectDuplicateAssets" function, below line of code appends list of assets to the response.
    duplicatedByMess += _g.XSS.getXSSValue(duplicatedBy[i]) + "<br>"; // line no 370
    So, I replaced it with below line of code.
    duplicatedByMess += "<br> <a href='/assetdetails.html"+duplicatedBy[i]+"' target='_blank'> "+duplicatedBy[i]+" </a>";
    Basically, I am adding <a> tag with href and target attribute.

Here is the final result.



When you hover over the list, you will see the redirecting links (check red box) in the bottom left of the page and when you click on the result, it redirects to "assetdetails" for corresponding page as shown below.




 

Work around for you guys:

Debug, in which scenarios "_detectDuplicateAssets" function gets called in fileupload.js.


Comments

Popular posts from this blog

Duplicate Asset Detection in AEM

Customizing Asset Upload Dialog