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 tag.

ListItemView3

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

ListItemView2

Avatar
Riwut Libinuko
Sr. Cloud Solution Architect

My research interests include distributed robotics, mobile computing and programmable matter.

comments powered by Disqus

Related