cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Attachment component in Task Form vs Request Form

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?

Labels: (1)
0 Kudos
Reply
5 Replies
Workflow Hero

Re: Attachment component in Task Form vs Request Form

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?

Accept as Solution Reply
Workflow Hero

Re: Attachment component in Task Form vs Request Form

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Attachment component in Task Form vs Request Form

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([]);
  }
});
}
Accept as Solution Reply
Workflow Hero

Re: Attachment component in Task Form vs Request Form

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.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Attachment component in Task Form vs Request Form

Can you please show me how to proceed on this?

0 Kudos
Accept as Solution Reply