We had a requirement to make the “clip” icon that indicates that a list item in SharePoint has an attachment clickable, enabling the opening of one of the attachments associated with that list. This ability seemed easy to me when it was requested, but it turned out to be somewhat harder than planned.
All the code for this was taken from this EXCELLENT post: Making the paperclip clickable – From SharePoint JavaScripts. The code provided by this site worked for me as-is. It is available from the author in versions that support SP2007 & SP2010. The reason for this post is that being as new to SharePoint as I am, it was not clear to me how to use the code that was provided. So this post details how I used the code referred to above. Please visit that site directly to get the latest code directly from the author, it is worth the trip.

The Solution
You will get two components from the source referenced above. A JS file to be added to your SharePoint server and a small snippet of JavaScript to be added to each SharePoint page you want to enable this functionality on.
JavaScript File
The first step is to deploy the JavaScript file to the server so it can be referenced from your web part(s) that may need it. There are probably numerous ways to do this. I chose to create a document library and add the JS file to that library. I was sure to configure the document library not to be visible from the site lest a user decide to go snooping. With the file in the library, it is easy to get a direct link to that file that we could then use in the web part to reference the required functions.
The Web Part
After deploying the JavaScript, go to the page you want to add this functionality to and shift it to Edit Mode. After the last list you want to make clickable, insert a Content Editor Web Part. This web part accepts raw HTML (including JavaScript). You can set the source of the web part to the script snippet provided making sure to update the reference to “ListAttachments.js” to point to your locally-deployed copy. That should be the only change you need to make. It is not required to hide the new web part, but there is nothing there to view so I would hide it (in the Layout section of the Web Part editor).
Notes
- You need the ID on any view this is to interact with. Without the ID field, you will see an error reported from the scripting layer. The tool give you the ability hide the ID, so adding it will not affect the user experience.
- Applying the JavaScript-based Web Part will affect all list views above it so even on a page with several list views you only need one Content Editor Web Part to get this to work.
- If a list item has more than one attachment, that is handled fine with no extra work on your part (see the screen grab above).
That is it, another thing that probably should just be “there” in SharePoint, but is not. Luckily as I found out, getting it added is a 15-minute job thanks to this shared code.