Sharepoint 2003: Auto Open List Attachment

English:

Actually this is a query from one of our client. They ask me how to make some list items automatically open its attachment. Although this can be done programatically, but I prefer Javascript approach.

Many task in web application can be accomplished using Javascript. Sharepoint using Javascript to create dynamic view for the users. For example you open DispForm.aspx of a list, it will dynamically hide/show Attachments information. Here you can see two item list, the first list has an attachment while the other hasn’t any.

ListItemView0

List item with attachment will show, Attachments row just like this picture,

ListItemView1

while list item without attachment will hide the Attachments row.

ListItemView4

It all provided by Sharepoint using simple Javascript that checks whether “idAttachmentsTable” object has rows defined. If that object has zero length rows, then it has no attachment. Hence, by checking “idAttachmentsTable” object and digging to url child nodes we can grab location of the attachment. Passing the location of the attachment to document location will then open list item attachment automatically.

So, start to open DispForm.aspx of the list, and insert custom javascript just above closing </BODY> tag.

ListItemView3

Save the modification, and if you click on list item with attachment, it will open the attachment automatically.

ListItemView2

About

Riwut Libinuko, experienced Architect. Currently working with Credit Agricole CIB, responsible for SharePoint platform in Asia Pasific. . Certification: SharePoint 2013, SharePoint 2010, SharePoint 2007, ITiL v3

Posted in Microsoft Sharepoint, Tips and Tricks
One comment on “Sharepoint 2003: Auto Open List Attachment
  1. Jalil says:

    Thank you for your help. Do you know how you can create a link in the listview for an attachment? For example, in your first screenshot, there are two lists, one with an attachment and one without. The one with an attachment only shows a picture of a paperclip but now way to open the attachment. Is there a way to display the attachment name and link in the list view?

    Thank you for your help.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: