Wednesday, April 25, 2012

Display Item Attachments in SharePoint List View

It is very easy to display list item attachments
in List View and also manipulate the display of attachment, like if attachment is
image, we can display image not just a link.
1. Open List View in SharePoint Desinger
2. Add new column titled "Attachments".
3. Select TD tag of New column.
4. Replace selected code with below code.


 <td id="ItemAttchment" class="ms-vb">
          <xsl:element name="SharePoint:AttachmentsField">
          <xsl:attribute name="runat">server</xsl:attribute>
                    <xsl:attribute name="FieldName">Attachments</xsl:attribute>
          <xsl:attribute name="ControlMode">Display</xsl:attribute>
          <xsl:attribute name="Visible">true</xsl:attribute>
          <xsl:attribute name="ItemId">
              <xsl:value-of select="@ID"/>
          </xsl:attribute>
          </xsl:element>
</td>


5. View with Attachments

48 comments:

  1. I had a problem after pasting the XSLT code from Step 4. The following error showed in the table cell of the new column:

    Error Rendering Control - Unnamed1Cannot create an object of type 'System.Int32' from its string representation '3af427e6-b3f9-4313-96b7-bde7bf693afd' for the 'ItemId' property.

    ReplyDelete
    Replies
    1. Had the saqme Problem - you're getting the ID of the Attachment column, you need to select the ID of the Sharepoint List Item:
      <xsl:value-of select="$thisNode/@ID"></xsl:value-of>
      Hope this works for you

      Delete
    2. I had the same problem and tried Martin solution but still I have the same problem. Any ideas?

      Delete
  2. Hi, Any idea if this can be done to a XsltListViewWebpart added dynamically to a list form?

    ReplyDelete
  3. It seems that if the attachment isn't added to the list item initially OR the attachment is changed for that list item later, it doesn't update the link on the view.

    ReplyDelete
  4. thanks...great work...helped me before my presentation !!!!!

    ReplyDelete
  5. Yes it is working fine , thanks for sharing such a nice information it was really helpful.

    ReplyDelete
  6. It seems that if the attachment isn't added to the list item initially OR the attachment is changed for that list item later, it doesn't update the link on the view.

    ReplyDelete
  7. While sorting the view the attachments are not been sorted

    ReplyDelete
  8. How could I sort the attachments when the list items are sorted?

    ReplyDelete
  9. Hi, That's all working great, but how can I display the URL to the attachment as an image? Thanks.

    ReplyDelete
  10. Dinesh and Luis, Did you figure out a way to avoid the issue of attachment displaying old file when we modify the attachment or sort the list?
    Thanks
    Nate

    ReplyDelete
  11. can we change the display name of attachments? for example, more information instead of amit_cv.docx

    ReplyDelete
  12. Hi. I also have a problem with the sort of attachments. When you apply a filter attachment does not correspond to the list items.

    ReplyDelete
  13. Hi there - How to do this in SharePoint 2013? Designer doesn't show Design view window.

    ReplyDelete
  14. Hi there - I was able to achieve it but now the problem is that since I customized the View page, It is not coming in the list of views and hence i couldn't export items to Excels. :-(

    Thanks Amit for posting this article. In a way your article was helpful.

    ReplyDelete
  15. How to do this in SharePoint 2013? Designer doesn't show Design view window.

    ReplyDelete
  16. How to do it on SharePoint 2013 ?

    ReplyDelete
  17. Can you help with the multiple attachments within a list entry. I am able to display the attachments now and want to show "last modified by" for each of them ? Any pointers ??

    ReplyDelete
    Replies
    1. Santosh, I'm trying to figure this out too, have you had any luck?

      Delete
    2. I tried this, but no success, I could not able to find the XSLT file. I am using SharePoint O365. so I followed steps from below url and it worked.


      https://social.technet.microsoft.com/Forums/en-US/74dac191-5a9e-4970-a9f6-a501846f0bef/forum-faq-show-attachments-in-sharepoint-2013-custom-list-view?forum=sharepointgeneral&prof=required

      Delete
  18. Very nice article. Working fine for lists. But I was unable to get this to work for form library.

    I have a form library with an attachment field. So when the form gets submitted I need the hyperlink of the attachment in the SharePoint list view. Any suggestions??

    ReplyDelete
  19. Thanks for the help that works perfectly after replacing

    ReplyDelete
  20. The attachments are not sorting when you change the sorting in any of the other columns, is there a fix for this?

    Thanks

    ReplyDelete
    Replies
    1. I suppose I should clarify that it is not filtering when I filter another column.

      Delete
  21. where exactly do i have to paste the code?

    ReplyDelete
  22. I was able to use this for SP2010, but we are now moving to SPOnline (using SPD2013). Do you have a similar solution when SPD2013 does not allow Design or Split mode?

    ReplyDelete
  23. Yes also wondering how to do this in SPD 2013 ? Thx

    ReplyDelete
  24. Hi All,
    There is a way to do it in SharePoint Designer 2013 also. What I did is to create a "DataSource" in SharePoint designer 2013 (SOAP - Lists.asmx) even if your list exists in the same site. After creating the datasource, I went to the webpart page and added the "Data View" webpart and modified it as mentioned in this blog. I have tested this in my dev machine and it is working.

    PART 1- http://blog.jonathanroussel.com/2009/05/sharepoint-walktrouh-displaying-list.html

    PART 2- http://blog.jonathanroussel.com/2009/05/sharepoint-walktrouh-displaying-list_28.html

    Hope someone find this useful.

    ReplyDelete
  25. ayo deh coba KLIK buat dapetin uang lebih

    ReplyDelete
  26. This works for me when I view the listview alone but it the column I have added "disappears" when I embed this listview in wikipage or publishing page. It not only doesn't appear it seemingly gets stripped out when I view the html in the dom explorer. Does anyone know why it is doing this? I'm using sharepoint 2010 :-(

    ReplyDelete
  27. sabung ayam filipina juga di kenali dalam indobnesia, bolavita merupakan salah satu agen terbesar... WA: 081377055002

    ReplyDelete
  28. anyidea how to get this soution in o365 or SP2016

    ReplyDelete
  29. Do you understand there's a 12 word phrase you can tell your partner... that will trigger intense emotions of love and instinctual attractiveness to you buried inside his heart?

    Because deep inside these 12 words is a "secret signal" that triggers a man's instinct to love, worship and care for you with his entire heart...

    12 Words That Fuel A Man's Love Impulse

    This instinct is so built-in to a man's mind that it will drive him to work better than before to take care of you.

    Matter-of-fact, triggering this mighty instinct is so essential to getting the best ever relationship with your man that once you send your man a "Secret Signal"...

    ...You'll soon find him expose his heart and soul to you in such a way he never experienced before and he'll perceive you as the only woman in the world who has ever truly attracted him.

    ReplyDelete
  30. Your Affiliate Money Making Machine is waiting -

    And getting it set up is as easy as 1-2-3!

    Here's how it works...

    STEP 1. Input into the system what affiliate products you want to push
    STEP 2. Add PUSH BUTTON TRAFFIC (it ONLY takes 2 minutes)
    STEP 3. See how the affiliate products system grow your list and sell your affiliate products all on it's own!

    Do you want to start making money??

    Your MONEY MAKING affiliate solution is RIGHT HERE

    ReplyDelete
  31. Telah hadir di bolavita deposit via pulsa telkomsel dan XL Rate terbaik se indonesia
    dan banyak bonus2 mendarik lain nya min depo 25 rbu bisa jadi jutawan
    ayo segera daftar dan buktikan sendiri

    info lbh lanjut:
    WA: +62812-2222-995

    ReplyDelete
  32. This comment has been removed by the author.

    ReplyDelete