0

I am trying to use JSOM to programatically move existing files in a document library to a document set within the same library. I think I should be able to use SP.MoveCopyUtil.MoveFile for this purpose. The issue is that MoveCopyUtil does not show up in intellisense. When I manually type it in, I get an error: Property 'MoveCopyUtil' does not exist on type 'typeof SP'.

In config.json, I have the following entries:

...
    "sp-runtime": {
      "path": "https://ca03.sharepoint.com/_layouts/15/SP.Runtime.js",
      "globalName": "SP",
      "globalDependencies": [
        "microsoft-ajax"
      ]
    },
    "sharepoint": {
      "path": "https://ca03.sharepoint.com/_layouts/15/SP.js",
      "globalName": "SP",
      "globalDependencies": [
        "sp-runtime"
      ]
    },
    "sharepoint-doc-mgmt": {
      "path": "https://ca03.sharepoint.com/_layouts/15/SP.DocumentManagement.js",
      "globalName": "SP",
      "globalDependencies": [
        "sharepoint"
      ]
    }
...

And in the webpart itself the following statements are in place:

require('sp-init');
require('microsoft-ajax');
require('sp-runtime');
require('sharepoint');

In fact, I'm using SP.js and SP.DocumentManagement.js already to create document sets. So I don't know why the MoveCopyUtil is unavailable.

Any insight would be greatly appreciated.

Thanks.

0

Try this:

Beneath import , define

declare var SP:any; 

Load libraries:

public render(): void {
    SPComponentLoader.loadCss('/_layouts/15/1033/styles/corev15.css');  

    SPComponentLoader.loadScript('/_layouts/15/init.js', {
      globalExportsName: '$_global_init'
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/MicrosoftAjax.js', {
        globalExportsName: 'Sys'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/ScriptResx.ashx?name=sp.res&culture=en-us', {
        globalExportsName: 'Sys'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/SP.Runtime.js', {
        globalExportsName: 'SP'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/SP.js', {
        globalExportsName: 'SP'
      });
    })
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/sp.init.js', {
        globalExportsName: 'SP'
      });
    })        
    .then((): Promise<{}> => {
      return SPComponentLoader.loadScript('/_layouts/15/sp.ui.dialog.js', {
        globalExportsName: 'SP'
      });
    });

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.