SharePoint 2019 javascript SP.MoveCopyUtil.copyFile not working across site collections

Damien Barafort 1 Reputation point
2021-04-18T18:52:51.447+00:00

In SharePoint 2016, I was happily surprised to benefit new javascript functions available in SharePoint : SP.MoveCopyUtil.* to get out of the hell of copying files in SharePoint.

The following peace of code was working like a charm : var context = SP.ClientContext.get_current(); SP.MoveCopyUtil.copyFile(context,fileUrl,destUrl);

even when destUrl being in another site collection.

Unfortunately, after the migration to SharePoint 2019, it does not work anymore. It works only if destUrl is in the same site collection. How can I do? I there a problem with SharePoint 2019 js files?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,897 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Damien Barafort 1 Reputation point
    2021-09-21T09:57:54.36+00:00

    Hi. Thanks a lot for your support Jerryzy, sorry for the delay but ...

    So... After many many tests, here are my conclusions :

    • GetFileByServerRelativePath , GetFileByServerRelativeUrl, GetFolderByServerRelativeUrl ... do not work as soon as it is performed in another site collection (same as SPMoveCopyUtil). So I could not use your example, and then...
    • I tried to use SPServices, I failed
    • At last I used SP.FileCreationInformation using the same technique as in your example (loading the file in memory and then creating the file at the destination) and finally ... it run!!! ...
    • until a big file had to be copied, I had to change the server limits for API size limit (https://sharepoint.stackexchange.com/questions/111573/sharepoint-2013-javascript-code-for-file-upload-max-limit-exceeded/157307)

    I am happy it runs nows, but I am really disappointed when I think about all the time spent. Javascript + API bugs -> lot of pain :-)

    0 comments No comments

  2. Damien Barafort 1 Reputation point
    2021-10-20T10:22:57.377+00:00

    Hi!
    Unfortunately :

    • I forgot I had another automatic process, copying folders... So, same bug here; and replacing a simple line of code with SPMoveCopyUtil with a recursive call (recursive because of looping on files and javascript async way of doing) is in my opinion too much job for the money (next step : writing assembly language for the stuff...)
    • last SharePoint updates, applied to the farm, did not correct that bug

    So please Microsoft, ... DELIVER. Correct the bugs, including SharePoint on premise versions. Please.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.