Find duplicate items in SharePoint

By Namwar Rizvi - Last updated: Wednesday, December 22, 2010 - Save & Share - One Comment

There are some situations when two different users of SharePoint upload same document with two different names. This mostly happens when both of them do not know that someone else has already uploaded same document earlier. SharePoint displays the “[View duplicates]” link when it finds duplicate items for a given search result.

On clicking the “[View duplicates]” link, you will notice that SharePoint searches the duplicate items by creating a keyword query of “duplicate:Full Document Url

To make our life easier, I have created a Feature which will add a context menu item in ECB and will allow user to directly find duplicates for any item, from the context menu, without first going to the search page.

To get the idea, here is a snapshot of what you will get once our feature is activate:

ECB View Duplicates

Edit Control Block Menu for View Duplicates Option

User will just click on View Duplicates option and will get all the duplicate documents for the selected document.

Implementation:

  1. Create a folder named ViewDuplicates under FEATURES folder of your SharePoint installation.
  2. Create a file called Feature.xml under ViewDuplicates folder.
  3. Paste the following code in Feature.xml:
  4. <?xml version="1.0" encoding="utf-8"?>
    <Feature  Id="960206DD-D07E-4b64-AD8A-3E48D7527060"
              Title="View Duplicates"
              Description="This feature allows user to view duplicate copies of the selected document."
              ImageUrl="CALVIEW.GIF"
              Version="1.0.0.0"
              Scope="Site"
              Hidden="FALSE"
        xmlns="http://schemas.microsoft.com/sharepoint/">
      <ElementManifests>
        <ElementManifest Location="elements.xml"/>
      </ElementManifests>
    </Feature>
    
    
  5. Create a file called Elements.xml under ViewDuplicates folder.
  6. Paste the following code in Element.xml:
  7. <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    
      <!-- Per Item Dropdown (ECB) Link -->
      <CustomAction Id="ViewDuplicates.ECBItemMenu"
        RegistrationType="List"
        RegistrationId="101"
        ImageUrl="/_layouts/images/GORTL.GIF"
        Location="EditControlBlock"
        Sequence="300"
        Title="View Duplicates">
        <UrlAction Url="javascript:function findDuplicates(){var itemUrl='{ItemUrl}'; var fullUrl=location.protocol+'//'+location.host+itemUrl;  window.location.href='/Search/results.aspx?k=duplicates:&quot;'+ fullUrl + '&quot;'};findDuplicates();"/>
      </CustomAction>
    
    </Elements>
    
    
  8. Install the feature by executing stsadm -o installfeature -name ViewDuplicates
  9. Activate the feature by executing stsadm -o activatefeature -name ViewDuplicates -url <YourSiteCollectionUrl>. Replace <YourSiteCollectionUrl> by the url of your site collection.
  10. Now, you will get “View Duplicates” option with every document. Click it and Enjoy!
Share
Posted in Code, Feature, How To, Information, Search, Solutions, SP2010 • Tags: , , , , , , , , Top Of Page

One Response to “Find duplicate items in SharePoint”

Comment from Dan Cooper
Time January 6, 2011 at 3:36 pm

Thanks, nice and useful

Write a comment