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

Flexi-Task Attachments

Jump to solution

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

0 Kudos
Reply
5 Replies
Workflow Hero

Re: Flexi-Task Attachments

Jump to solution

Hi,

Please have a look on this:

 

0 Kudos
Reply
Workflow Hero

Re: Flexi-Task Attachments

Jump to solution

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
Workflow Hero

Re: Flexi-Task Attachments

Jump to solution

Hi Diana,

I am a little confused, so .. if I have two Flexi Tasks. The first one is presented to one Approver 1  (in Flexi Task 1)  who will upload a document for the second Approver in line which will be presented with the second task (Flexi Task 2) where I want to show the attachments provided by Approver 1 submitted in Flexi Task 1.

From your post, I understand I should add this code in Flexi Task 1, but I get confused with the Caclulated Value... where do I put this one, in Flexi Task 1 or  Flexi Task 2 (where I want to show the attachments submitted in Flexi Task 1)?

Thank you so much for your help

Giselle

0 Kudos
Reply
Workflow Hero

Re: Flexi-Task Attachments

Jump to solution

Hi Giselle,

The way I have my form set up is that the attachments are pulling through from the form to the Flexi-Task.  It sounds like you are having attachments added in the Flexi-Task, do I have that correct?

0 Kudos
Reply
Workflow Hero

Re: Flexi-Task Attachments

Jump to solution

Hi Diana,

Yes. That's is correct. I understand your solution now. It very helpful as

well

Thank you so very much!

Happy Holidays!

Best,

Giselle

0 Kudos
Reply