-1

I am creating Custom Menu Item in SharePoint 2016. A custom menu basically copies file from one location to another. I am using SP.MoveCopyUtil.copyfile() method with the parameters:

  • context
  • sourceURL
  • destinationURL
  • overwrite - (boolean true/false)

The last parameter is not affecting the functionality of the method, even if I remove and execute the method it works.

The issue here is that I am not able to overwrite a file which already exists in the destination.

Lukas Nespor
  • 1,238
  • 1
  • 14
  • 22
Prabhanath
  • 98
  • 1
  • 7
  • What language do you use? Javascript or .NET CSOM? Can you provide example code, so web can see how you are using it? – Lukas Nespor Feb 28 '19 at 13:47

1 Answers1

-1

Hey i'm also facing similar issue , was trying to create a custom menu in Share-point 2016. The custom menu and everything gets created and its also able to copy the files , its just we are not able to overwrite the existing file in the destination folder.

**SP.MoveCopyUtil.copyFile(context, source, destn);**
        context.executeQueryAsync(
            function () {
                alert("The file was copied successfully");
                location.href = sourceLib;
            },
            function (s, a) {
                alert(a.get_message());
                location.href = sourceLib;
            }
        );

Here we can pass a flag to overwrite boolean value (true/false). But it doesn't quite affect the working of this method. SP.MoveCopyUtil.copyFile(context, source, destn,true); Context - is the context of the current page source - is the source URL from where we need to copy the file i.e. xyz.com/test.txt destn - is the destination URL from where we need to copy the file i.e. xyz.com/test.txt

Prabhanath
  • 98
  • 1
  • 7
  • Quick update on this one guys : We tried the same piece of code on O365 (Sharepoint - online) , seems like sharepoint-2016 (On premises) might require some patching or updating the js files. So that the code works in sharepoint-2016. Code-wise its good , its working on O365 – Prabhanath Mar 06 '19 at 06:26