Skip to main content

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

Hi,

Please have a look on this:

 


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");
     }                    
    });
   });


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


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?


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


Thanks a lot, it worked direct!!! 



 



happy wheels


Is it work with you?


Thankyou @DinaF this actually worked.
offshorededi


Thanks a lot, it worked !!! 



offshore server


@DinaF 



I see how you try to add the attachments from the form on the flexi task form. i have a different issue.



I am trying to show the attachments added by approver1 on the flexi task form of approver2.



since the attachments added on the flexi task will be in the workflow tasks list and each flexi task has a different ID, how can i show the attachment added from the approve1 to approver2 flexi task



is it something you can help me with?


The answers must have really helped.

basketball


Sadly its not working any more.


Working for me only to first flexi task approval but not for the rest of the flexi task approval tasks

Reply