Copying file across sites = Exception: Object reference

by Rob_CTL » Mon Jan 16, 2017 10:18 am

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: https://company.sharepoint.com/site/sit ... documents/[%Current Item:Name%].[%Current Item:File Type%]

Target Address: https://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
Rob_CTL
 
Posts: 10
Joined: Sun Dec 06, 2015 5:16 pm

by Rob_CTL » Mon Jan 16, 2017 2:54 pm

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 https://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
Rob_CTL
 
Posts: 10
Joined: Sun Dec 06, 2015 5:16 pm


Return to Workflow Actions Pack for Office 365