How to Copy files from one site collection document library to another collection multiple sites document libraries?

  • 24 October 2016
  • 6 replies
  • 13 views

Badge +3

Hi Everyone,

I've been trying everything to make this work, but failing miserably and could really use any direction from you guys please!

The facts:

- I have a folder on site in one site collection

- This folder has multiple spreadsheets

- Every month, these spreadsheets get updated

- Each spreadsheet should then be Copied into its relative site which reside in a different site collection

What I would like the Site workflow to do:

- Run every month

- Copy all spreadsheets

- Paste the right spreadsheet in its relative site's document library

This is the 1st portion of my Site workflow where I Query the document library and get the Spreadsheet names, URLs and GUID all stored in Collection VARs. Then using the For each.

193527_pastedImage_5.png

At this point, I literally have everything I need and just want to copy the right file to right Site.

progress.gif

193523_pastedImage_1.png

To determine which Site the File should be copied into, I'm using the Switch where each FileName is exactly equal to the spreadsheet name in the Source Folder:

193524_pastedImage_2.png

To get the Destination URLs, I plan to Build a String under every Switch Branch and store each Destination URL into a string VAR and Set Variable where FileURL = Destination URL.

Finally (and this is the part I'm having major trouble with) comes the Copy Items using Call Web Service: This is what it looks like

193525_pastedImage_3.png

And this is the error I get:

193528_pastedImage_6.png

What am I missing?


6 replies

Userlevel 6
Badge +12

Hello M K‌ - 

You can do this and you are on the right track.

I created a site workflow on the Source site and am using the following workflow variables within:

193627_pastedImage_13.png

Keeping with your approach, you really only need to query the Encoded Absolute URL of the item along with the Name (to get the file name for later). So using the good 'ol Share Documents Library for an example, it would look like this:

193619_pastedImage_3.png

I placed one test excel file there and when I Run Now, I see this:

193621_pastedImage_5.png

Keep in mind, you'll have a Collection of items, not just a single file.

Next, you simply need use a For Each loop to loop through your collection of items to separate them out one at a time. Something like this:

193622_pastedImage_6.png

For Each:

193623_pastedImage_7.png

At this point, we have the Source URL for our web service call. Now we need to build the URL for Destination.

First we need to get the file name and extension. We can do this by extraction the file name from our other collection:

Collection Operation:

193624_pastedImage_8.png

Here is where you want to add your logic of the switch to determine where it will land. After you determine that piece of it, simple use a Set Variable action to set the var_DestinationURL. It will look something like this:

http://DestinationSiteCollection/DestinationLibrary/var_FileName

We now have all the pieces to push the item over to your destination. We can call the web service that you have, CopyIntoItemsLocal. Here is how it would look with the variables in place:

193626_pastedImage_12.png

Once you run the web service, increment the index by one and let the loop handle the next one!

You can add in Log to history actions through out the workflow to check the URLs to ensure they are accurate, and I would recommend doing that so you do not republish and rerun multiple times!

Hope this helps!

Badge +3

Thank you very much Jesse – This helped a lot ☺

Userlevel 6
Badge +12

Always happy to help! Glad you got it working!

Badge +2

This is something i'm trying to get done in O365. Do you know what the equivalent actions for the Query list is. I can't seem to find the right process to get the URL and the name into the two collection variables. Thanks!

Badge

Hi Yoav, you can still use Query list in Nintex Office 365 for bulk uploading/editing but what I used to copy the current document was the Office 365 Upload File action.

Badge
Can I create List Workflow instead of Site Workflow. My purpose is whenever user upload a document to a DL it should be copied to another DL in different SC.

Reply