Skip to main content
Nintex Community Menu Bar
Solved

Flexi-Task Attachments

  • Aug 22, 2018 1:26 PM UTC
  • 13 replies
  • 222 views
  • Translate All

Forum|alt.badge.img+7

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

Best answer by DinaF

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

View original

13 replies

Forum|alt.badge.img+7
  • Nintex Partner
  • Aug 22, 2018 8:25 PM UTC

Hi,

Please have a look on this:

 

Translate

Forum|alt.badge.img+7
  • Author
  • Answer
  • Aug 24, 2018 1:19 PM UTC

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

Translate

Forum|alt.badge.img+2

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

Translate

Forum|alt.badge.img+7
  • Author
  • Nov 26, 2018 2:54 PM UTC

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?

Translate

Forum|alt.badge.img+2

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

Translate

  • Novice
  • May 30, 2019 7:01 AM UTC

Thanks a lot, it worked direct!!! 

 

happy wheels

Translate

Forum|alt.badge.img+1

Is it work with you?

Translate

Thankyou @DinaF this actually worked.
offshorededi

Translate

  • May 21, 2020 8:45 AM UTC

Thanks a lot, it worked !!! 

offshore server

Translate

Forum|alt.badge.img+3
  • Rookie
  • Aug 17, 2020 3:42 PM UTC

@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?

Translate

The answers must have really helped.

basketball

Translate

  • Jul 7, 2021 10:19 AM UTC

Sadly its not working any more.

Translate

  • Oct 20, 2021 10:21 AM UTC
Working for me only to first flexi task approval but not for the rest of the flexi task approval tasks
Translate