AddAttachment web service not working

  • 10 February 2017
  • 8 replies
  • 61 views

Badge +3

I am Trying to use the Nintex Call web service workflow actions AddAttachment web method to attach a library contained document (where the workflow is running, to a form/document in a list. The library containing the document is hidden from users but the list documents are visible. Once the document is attached, it will be deleted from the library. The code is:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/sharepoint/soap/">
  <soap:Header>
  </soap:Header>
  <soap:Body>
    <m:AddAttachment>
      <m:listName>HR Nominations</m:listName>
      <m:listItemID>{ItemProperty:ID}</m:listItemID>
      <m:fileName>{ItemProperty:FileLeafRef}</m:fileName>
      <m:attachment>[FileData]</m:attachment>
    </m:AddAttachment>
  </soap:Body>
</soap:Envelope>

where "HR Nominations" is the name of the list containing the Nintex form/document resides and "ItemProperty:ID is the ID of the document to be attached. This looks correct, but throws the following error:

Failed to invoke web service. Error returned from server: <soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

Any ideas or suggestions? There could be one or more documents, of various formats, to be attached.

The application is one where employees are nominated for various awards on a public site where the nomination form is available, and nominations bight be supported by attached documents. The nomination form, when saved, starts another workflow via a "Call web service" action. This workflow copies the form information to the private HR site for further action. The attachments are copied to a hidden library on the private HR site. The original, public record is then deleted. Personnel in HR receive an email message letting them know that a nomination has been submitted. (Once the supporting document(s) have been attached to the nomination, it/they are deleted from the hidden library.

Thanks for your help!

Bill


8 replies

Userlevel 7
Badge +17

I believe that m:listItemID is the string that contains the ID of the item to which attachments are added. I don't think you have that by using the itemproperty:ID. This would need to be the destination list item to attach the document to.

Also, a good walkthrough that takes task attachments and copies to list items as attachments.

Badge +3

Thank you Andrew. My problem is having the “ItemID” available in the hidden library where the attachment(s) is/are located. The “ItemID” is available with the original form when the copy is created in the private list. (The private list and hidden library are on the same site.) I am not sure how to copy the “ItemID” from the public list to the hidden library on the private site so I can then use it to reattach the documents to the form.

Bill

Applications

Userlevel 7
Badge +17

It may depend on how you are creating the item, what action(s) are you using?

Userlevel 7
Badge +17

Oh, and could the two lists be identical between the Public site and HR site? Both be lists with forms and allow document attachments. Then using the copy action, you should get the attachment. I'm not sure though if the library is required for your processes.

Then HR will get a notification to review, then once they complete the review you can then delete the attachment and not the list item to complete the process.

Badge +3

Thanks for your response Andrew. Let me look this over and get back to you sometime tomorrow if I possibly can. Again, thanks for your suggestions and I will provide additional info as well.

Bill

Applications

Badge +3

Andrew,

Sorry about the delay in getting back to you. After reviewing your suggestions and the workflows that we have been working on, it turns out that the problem was caused by the query in the second workflow. The filtering used was incorrect, and once that was resolved, all worked fine. I want to thank you for your help and patience in working with me on this.

Bill

Applications

Badge +9

I think i have the same issue and i am only trying to get the base64 from the attachments. Would you be able to show how?

Badge +1

Hi Bill,

 

I am trying to implement the same thing on nintex 365, but getting error for [fieData] token. Can you please provide screen shot for the same. My requirement is to attach a file to an existing list item id.

 

Thanks 

 

Reply