Need link to attachment from a list.

I've got a user who has a very large SharePoint list, to which she is attaching files (normally, I'd recommend a Document Library, but that's its own story).  She wants to be able to have a direct link to the attached file as a list column.  Much to my surprise, this is not possible OOTB.

I've seen this described for 2007 elsewhere, but was unsuccessful in adapting it to SPD 2010.  Has anybody encountered a solution for this for 2010, or know how the 2007 solution could be adapted?

Many thanks!

January 16th, 2014 1:15pm

Hi Josh, maybe I'm not getting the entire picture, but why don't you add a links column, grab the attachment URL from the list item and add it to the links column? OR are you trying to have this automated somehow?
Free Windows Admin Tool Kit Click here and download it now
January 16th, 2014 2:43pm

Hi Josh,

From your description, Id recommend you create a new column for attachments in the current list. Here are the steps:

1.In the List Tools > List > Modify View > Modify in SharePoint Designer (Advanced).

2.Then you come to SharePoint Designer 2010. Switch to Split view and locate the column. Then right-click and insert Column to the Right.

3.Then locate the td part as below:

<td><xsl:text xmlns:ddwrt="http://schemas.microsoft.com/webparts/v2/data....
</td>

4.Replace it with the code as below:

<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.Then view in the IE browser and see if it works as expected.

The screen shot below is the result from my lab environment:

Re

January 17th, 2014 3:32am

Rebecca, I was successful in adding the column, but get the following error in all cells in the new column:

"Error Rendering Control - Unnamed1.  Cannot create an object of type 'System.Int32' from its string representation '9b9bce61-31e2-4e08-93f6-0290dd3e7889' for the 'ItemId' property.

When I load the page, I get a similar error:

"Cannot create an object of type 'System.Int32' from its string representation '9b9bce61-31e2-4e08-93f6-0290dd3e7889' for the 'ItemId' property.

Troubleshoot issues with Microsoft SharePoint Foundation.

Correlation ID: cf94f487-6bd7-4d88-b6ca-2b486e206dcf"

Any idea on what could be causing this?  I'm going to try to troubleshoot.

Thanks!



  • Edited by Josh Loomis Wednesday, January 22, 2014 11:09 PM
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2014 9:33pm

Still can't figure out the source of the error.  Any ideas?
January 23rd, 2014 9:48pm

Okay, I figured it out.  I modified the code, such that:

<td id="ItemAttchment{$ID}{generate-id()}" 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="$thisNode/@ID" /></xsl:attribute>
</xsl:element>
</td>

Followup questions:

  1. Is there a way that I can display text in place of the filename for the hyperlink?  Something like "Download file" or the like?
  2. How do I go about creating a column header with the same controls (e.g., sort, filter, etc.) as column headers have?

Thanks!

Josh

Free Windows Admin Tool Kit Click here and download it now
January 27th, 2014 10:00pm

Hi,

Please create  new threads for different issues. It will be better for support engineer and forum viewer to track/search/read the thread. Cheers.

January 29th, 2014 4:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics