0

I am trying to move a file from one folder to another on my SharePoint 2013 server. I tried using the answer with 5 upvotes on this link: How do I move files from one document library to another using JSOM?.

But, when the script hits var folderSrc = web.getFolderByServerRelativeUrl(sourceLib);, an error message appears in the console:

Object doesn't support property or method 'getFolderByServerRelativeURL'

I'm guessing web was not properly loaded. What do I need to do to load web correctly?

4
  • 2
    can you paste you whole code? where are you running this in document.ready? Dec 4, 2019 at 17:28
  • I am unable to paste the code for reasons. This function is ran within a button's click() method call in document.ready. Dec 4, 2019 at 17:29
  • It seems that your context and web object is not intialized Dec 4, 2019 at 19:22
  • Could you post at least part of the code, modifying what you don't what us to see? More specifically, how are you getting this web variable and what are you doing with it before this call. Dec 4, 2019 at 21:58

1 Answer 1

1

run your code under this

SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {
      var clientContext = new SP.ClientContext.get_current();    

      //write code here to get web object and then server relative url 

});
1
  • This worked, thank you everyone for your help! Dec 5, 2019 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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