How do you access attachments, that are included on a form, from a Flexitask approval screen?
Flexi-Task Attachments

Best answer by DinaF
You will want to add the below JavaScript code to the Custom JavaScript, in Settings, of the Flexi-Task form . It does an API call to get the item, including the attachment information, which then generates html for the links and adds the information to the calculated field. This enabled the Flexi-Task approval form to pull the attachments from the list to the approval page. You will want to delete the attachments field form the Flexi-Task form and add a calculated field with a CSS Class of attachmentField.
Nintex kept replacing the <br /> tag with a new line in the script even though it was in quotes as part of a string. So you can see in the script there is a “<faketag>” tag and then I replace “faketag” with “br /“. This was the only way to get the code to work properly.
NWF$(document)
.ready(function()
{
// Rest URL
var requestUri = "Site URL/_api/lists/getbytitle('ListName')/items(ID)?$expand=AttachmentFiles";
var attachmentsHTML = '<div>';
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data)
{
$.each
(data.d.AttachmentFiles.results,
function (i, item)
{
var x = item;
var attachmentUrl = item.ServerRelativeUrl;
var fileName = item.FileName;
attachmentsHTML += '<a href="' + attachmentUrl + '" target="_blank" >' + fileName + '</a>' + '<faketag>';
attachmentsHTML = attachmentsHTML.replace("faketag","br /");
}
);
attachmentsHTML += '</div>';
NWF$(".attachmentField").html(attachmentsHTML);
},
error: function ()
{
alert("Error getting the Item Attachments");
}
});
});
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.