Categories

Archives

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

Related Posts:

  • No Related Posts

Facebook comments:

1 comment to Sharepoint 2003: Auto Open List Attachment

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

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>