Copying attachments from SharePoint items to task forms was always a hard thing to achieve. It might be possible but the effort is too high I think. When I need users to work with attachments I try to bring them to the initial request form by placing a link on my task forms. This way your attachments won't get split up onto task and request forms and it's still easy to achieve.
So basically my task form doensn't make much more than linking to the request form and grabbing a final comment before its completion.
Might this be an option?
Thanks for your reply. This might be the only choice if no other better & simple solution to go for.
I used the following work around to embed the workflow item attachments into task form.
1. Add a label control to Task Form with a CSS class name nf-Attachments added.
2. Append the following script in the custom JavaScript section of Nintex task Form.
3. Replace the placeholders in the script with the workflow item id and List name references.
4. Save the form and publish. That's it. Give it a go.
NWF$(document).ready(function () {
var lblAttachments = NWF$(".nf-Attachments label");
getItemAttachments("<<ItemId>>", "<<List Name>>", function (attachments) {
var html = "";
NWF$.each(attachments, function (i, file) {
html += "<a target='_blank' href='" + file.ServerRelativeUrl + "'>" + file.FileName + "</a> ";
});
lblAttachments.html(html);
});
});
function getItemAttachments(itemId, listName, callback) {
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")?$expand=AttachmentFiles";
jq$.ajax({
url: url,
datatype: 'json',
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json;odata=verbose");
},
success: function (data) {
if (data && data.d && data.d.AttachmentFiles && data.d.AttachmentFiles.results && data.d.AttachmentFiles.results.length > 0) {
callback(data.d.AttachmentFiles.results);
}
},
error: function () {
callback(/]);
}
});
}
Using the workflow you can get the name of the document attached from form data and create url for the document location and display that URL in rich text control on the task form.
Can you please show me how to proceed on this?