Attachment component in Task Form vs Request Form


Badge +1

I build a request form for new entry and a task form for rework purpose.  

For rework, user is editing the data via the task form. I can reuse the textbox which I have created in Request form and copied & paste it in task form. The textbox reflect the same data in task form and request form. However, this seems not working for attachment component. The attachment is not reflected in task form.

How to handle the attachment component in request form and task form for such implementation?


5 replies

Userlevel 4
Badge +12

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?

Badge +1

Thanks for your reply. This might be the only choice if no other better & simple solution to go for.

Badge +1

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([]);
  }
});
}
Badge +10

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.

Badge +2

Can you please show me how to proceed on this?

Reply