cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to include List Attachments to Task Approval Form

Jump to solution

Hello!

I would like to include a list attachment on my Nintex Task Form.  I tried using a hyperlink reference to the Item URL, and this does take me to where I can open the List attachment, but then I lose the Task Form and have to go back to the email to open it again.

I also tried the label control and configuring it so it would open the Link to the Item Property = Attachments, but that ends up taking me to a page that cannot be displayed.

Is there a way to add a control to the Task Form to show the List Item attachments?

It just seems to make sense to me to be able to click and open an attachment when performing an approval task.

Thank you!

Reply
17 Replies
Not applicable

Re: How to include List Attachments to Task Approval Form

Jump to solution
Reply
Not applicable

Re: How to include List Attachments to Task Approval Form

Jump to solution

Thank you for your response.  Unfortunately, this link did not resolve the issue.  So far, it appears that Nintex is unable to incorporate list attachment links to the Nintex Task Form.  I think this can be done using the SharePoint default task form though.

Reply
rahulprakash
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

Criss Chang‌ - Did you able to resolve the issue ? I have similar requirement. Client wants to see list item attachments on Task form before approving the request. Any thoughts?

Thanks,

Rahul 

Reply
powersj1
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

I ended up using javascript in order to get a list into my task forms.  Add the following code to your in your task form settings under Custom JavaScript.

function getListItemAttachments(SiteURL, ListName, ItemID) {
  if (ItemID) {
   var queryUrl = SiteURL + "/_api/web/lists/getbytitle('" + ListName + "')/items(" + ItemID + ")/AttachmentFiles";
    NWF$.ajax({
      url: queryUrl,
      type: "GET",
      async: false,
      headers: { "accept": "application/json; odata=verbose" },
      success: onQuerySuccess,
      error: onQueryError
    });
  } else {
    NWF$(".nf-attachments_rich_text").html('<i>No attachments.</i>');
  }
}
function onQuerySuccess(data) {
  var BuildHTML;
  var CountItems;
  BuildHTML = '';
  CountItems = 0;
  if (data) {
    //alert(JSON.stringify(data, null, 4));
    if(data.d) {
      NWF$(".nf-attachments_rich_text").html("1");
      NWF$.each(data.d.results, function(key, value) {
        BuildHTML = BuildHTML + '<a href="' + this.ServerRelativeUrl + '" target="_blank">' + this.FileName + '</a><b' + 'r />';
        CountItems = CountItems + 1;
      });
      BuildHTML = BuildHTML.substring(0,BuildHTML.length - 6);
      NWF$(".nf-attachments_rich_text").html(BuildHTML);
    } else {
      NWF$(".nf-attachments_rich_text").html('<i>No attachments.</i>');
    }
  }
  if (CountItems = 0) {
    NWF$(".nf-attachments_rich_text").html('<i>No attachments.</i>');
  }
}
function onQueryError(error) {
  alert(error.statusText);
}

Then I added a form variable name GetAttachments.  Set the formula for the variable to the following and use insert reference to replace with the Site URL and List Name common items. 

getListItemAttachments(Site URL,List Name,{ItemProperty:ID})

The last step is to add a Rich Text form control and change the CSS class to nf-attachments_rich_text. 

View solution in original post

Reply
raviteja_singam
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

I am getting "Forbidden" error at ajax call when i use the above code. I am using office 365. Could anyone please suggest how can i resolve the issue ?

0 Kudos
Reply
rahulprakash
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

Thanks Jeremiah Powers‌. Let me give it a try.

‌ : Let me also try. I also have office 365 I might hit the same issue. Did you able to find any solution ?

0 Kudos
Reply
raviteja_singam
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

‌ No i didn't get a solution yet.... I tried the same code in script editor web part and it works fine. Not sure what is stopping in Nintex forms...

0 Kudos
Reply
rahulprakash
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

Hi ‌ - I am also getting Forbidden popup window msg.

‌ - Do you know how to resolve the issue. I have attached image. I am using Office 365.

0 Kudos
Reply
rahulprakash
Nintex Newbie

Re: How to include List Attachments to Task Approval Form

Jump to solution

Quick update: Developer tool is showing error -- required Cross Origin Resource Sharing (CORS) 

Earlier in O365 it was not allowed but since 2015 CORS calls are fine. Don't know how to resolve.

0 Kudos
Reply