Sharepoint 2003: Auto Open List Attachment

By | January 24, 2007

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

2 thoughts on “Sharepoint 2003: Auto Open List Attachment

  1. Jalil

    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.

    Reply
  2. Jessica Honecker

    Hi there, I was wondering if I would be able to get the title of the attachment to show up in a view, so I can export the metadata to a spreadsheet. Once this is done, I want to be able to associate the metadata to the document that I have already moved over from a list to a library… So I can basically sort a-z on both lists and input the metadata.

    Reply

Leave a Reply