Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I require to programatically create a new document using the Document Template URL of the document Library and this requires to be done using the Client Object Model. I also require to do this without using workflow.

Could someone advise on how this can be done?

share|improve this question

1 Answer 1

You can try something like this:


  function createDocument()
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var docLib = web.get_lists().getByTitle("Docs");

    var rootFolder = docLib.get_rootFolder();

    var files = rootFolder.get_files();

        files.addTemplateFile(rootFolder.get_serverRelativeUrl() + "/foo.docx", 0);

      function(sender, args){alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());}

<div><a href="javascript:void(0)" onclick="createDocument()">Create Document</a></div>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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