0

I'm trying to show attachments on Boxed List View in SharePoint 2013. Hopefully this can be done with JavaScript or JQuery?

1

I got round this issue by using Infopath Designer to inject the filename part of the URL into a "simple line of text" field, and then a SharePoint designer workflow to build the complete URL.

The steps were as follows.

create a "single line of text" field in your list. I called mine "AttachmentURL"

Load infopath designer. and load your SharePoint list Right click on the "single line of text" field "AttachmentURL" and select "Text box properties"

enter image description here 4-In the "Default Value" section next to "Value", click the "Fx" button enter image description here

5-In the "Formula" dialog box, select the "Insert Field or Group" button enter image description here

6-In "Advanced view", expand the "Attachments" folder, and select the ":attachmentURL" icon and click "OK" all the way back to your form enter image description here

7-After making any other alterations in your form, publish the form to the SharePoint list

This gave me the attachment filename. I then used SharePoint Designer to build the rest of the URL :

Open SharePoint Designer and go to your list workflow You will now be able to build the Attachment's URL by creating a hyperlink that follows this construction : enter image description here

1
  • I guess you may have possibility using JavaScript/Jquery, but I didn't try through
    – Sara
    May 3 '17 at 19:04
0

You can get the list of attachments via REST calls. The boxed view doesn't usually have the ID in it unless you specifically add it.

I'd add the ID field to the box, then for each td value equal 'ID', I'd grab the id, then call the REST

/YOURSITEHERE/_api/web/lists/getbytitle('YOURLISTHERE')/items(THISIDHERE)/AttachmentFiles

Then loop through the response data.d.results, grabbing the ServerRelativeURL and the FileName, building up the links.

Then replace the row that has the ID with a row that contains the attachment links.

     var queryUrl = YOURSITEURL + "/_api/web/lists/getbytitle('MYLISTTITLE')/items(" + IDYOURETRIEVED + ")/AttachmentFiles";


        $.ajax({
            url: queryUrl,
            accepts: {
                json: "application/json;odata=verbose"
            },
            method: "GET",
            success: onQuerySuccess,
            error: onQueryError
        });

    function onQuerySuccess(data) {
        if (data) {
            $.each(data.d.results, function () {
                // build up links using this.ServerRelativeUrl and this.FileName
            });
        }
        // find the row with the id and replace it with your links, or whatever you want to do
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.