Link to attachment on SWE

Facebooktwitterpinterestlinkedinmail
Applies to version 2016.1.x; Author: Mariusz Burek

How to add attachment download links to your SWE Web Parts?

Calculated columns on the SWE Web Part offer virtually limitless possibilities to the user configuring them. One such capability is creating a column on the SWE report, which contains links to the last added attachment for each workflow instance.

Configuring a calculated column in this way is particularly useful in scenarios where the most important component of a workflow instance is a file attached to it. Whereas the workflow itself is used primarily as a means to organize those attachments, and offer additional methods of searching and sorting workflow content.

 

In order to create a link to an attachment on the SWE report, add a calculated column (SWE configuration -> Data selection -> Add calculated column). In the popup window (Fig. 1.) set the type to “Link” and enter the following query:

(select top 1 'link:/_layouts/15/webcon/ImageHandler.ashx?ATT_ID='+cast(ATT_ID as varchar)+';displayname:'+ATT_Name

from WFDataAttachmets where ATT_WFDID = WFD_ID order by ATT_ID desc)

 

NOTE! The parentheses were added purposefully and should not be removed.

 

column-config

Fig. 1. Configuration of a calculated column

 

After saving the configuration for the SWE Web Part and returning to the form, a user should be able to click the contents of the new column. This will cause a download confirmation message to appear (Fig. 2.):

save-attachment

Fig. 2. Saving an attachment from the SWE Web Part

4 thoughts to “Link to attachment on SWE”

  1. I copied the query in “SWE Configuration -> Data presentation -> Add calculated column”. After save this message appears:
    An error occurred while extracting data, Verify correctness of calculated columns.
    Incorrect syntax near ‘‘’. Incorrect syntax near ‘)’.

    1. Hello,
      The formatting I used in the query caused the single quotes to be changed to some other odd characters. The signs around ‘link:/_layouts/15/webcon/ImageHandler.ashx?ATT_ID=’ and ‘;displayname:’ strings should be just regular apostrophes/single quotes.
      I edited the article to remove the confusing formatting. Sorry for the inconvenience!

      Grzegorz Straś

      1. Thanks. It works. Unfortunately I have another issue. Clicking on the link of the attached document in SWE web part error “Sorry, something went wrong. An unexpected error has occurred. Troubleshoot issues with Microsoft SharePoint Foundation.” appears while clicking on the same document in workflow step (form) the document is opened.

Leave a Reply

Your email address will not be published. Required fields are marked *