Copying file across sites = Exception: Object reference

Hi,

I have two sites (top level sites in separate collections) - SharePoint Online. SiteA is the source site and SiteB is the target.

Within SiteA I have a document library with many items in it, there is a workflow attached to this library that allows users to copy documents over to a document library on SiteB.

Copying files from the root of the document library on SiteA to the document library on SiteB works perfectly. However if I try and send a file that is within a folder in the document library in SiteA to the SiteB I get the following error

Exception: Object reference not set to an instance of an object.

For information I am using the “Copy Document From” workflow Action.

Source Address: company.sharepoint.com/site/sit … documents/[%Current Item:Name%].[%Current Item:File Type%]

Target Address: company.sharepoint.com/site/sit … documents/[%Current Item:Name%].[%Current Item:File Type%]

The document library on SiteB doesn’t have the same file structure as the library on SiteA i.e. there are no folders. I am assuming this might be the issue for the error?

Thanks in advance
Rob

Ok, sussed it.

I had to change the source URL to [%Current Item:Server Relative URL%]. From logging this out I can see that this produces the full URL of the document. I had noticed that when I use the Workflow context the URL is formed using DispForm.aspx rather than a URL to the file.

Once the source was changed the target was set to company.sharepoint.com/site/sitea/documents/[%Current Item:Name%].[%Current Item:File Type%]

Once done the files would copy from sub-folders from the source library to the root of the target.

Cheers

Hi Rob,

I've been trying to get this to work all day, but no luck.
Your post helped me a to better understand what URL I have to use, but for some reason it only deletes my files. Any idea?