Copy List Attachments from one list to other List using Nintex

Business Requirement:

When we create an item with attachments  in the Parent List, it should copy the attachments from the parent item and paste the same into Child List. After pasting the attachments in the child list, we have to delete the attachments from the parent list item.

Approach tried and failed:

To copy List Attachments from one list to other List, we tried to use Add Attachment method using lists.asmx web service. But we got the following error:

“Failed to invoke Web Service. Object reference not set to an instance of an object”

Solution:

To implement this in Nintex,  we don’t have any way to directly copy attachments from a List Item to another List Item.

The reason is, the AddAttachment method is either looking for Base64 encoded binary data, or the [FileData] command.  The [FileData] command tells SharePoint to get the current files data.  But given that this is running a list item, there is no current file.

So the only workflow around I can think of, is this (you may hate this).

  1. Create a hidden Document Library that will be a temp storage of files.
  2. In your workflow on List1, add a Copy to SharePoint which for a List Item, it will copy the attachment to the configured destination Document Library (your hidden library).
  3. In your document library, create a workflow that starts on item creation.  Configure it with a Call Web Service action, and to call the AddAttachment web method.  This will now work, because this workflow is running on a file.
  4. Then you can configure the workflow to delete the current item to do a clean-up.

There may be some other things you will need to do like after the Copy to SharePoint, you may need to update something on that document which tells the workflow on that library which item you want to copy to.

So you might consider that doclib workflow not run automatically, and instead in your first workflow, Copy to SharePoint, Update an Item and then have a Call Web Service action to call the Nintex Workflow web servce to start a workflow on that document.

http://<siteurl>/_vti_bin/NintexWorkflow/Workflow.asmx

That has a StartWorkflow web method you could use.

Thank you Nintex Team, Saravana and Anil who helped me to implement this 🙂

Advertisements

About Joseph Velliah
As a SharePoint Developer my professional interests tend to be technical and SharePoint focused. I run a blog at "SP RIDER" where you can expect to read HOW TOs and scenarios that I run into during my day to day job. I hope my posts will give back a little to the community that is helped me.

One Response to Copy List Attachments from one list to other List using Nintex

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: