Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6850307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:06:30+00:00 2026-05-27T01:06:30+00:00

I want to create a copy of document in the SharePoint document library. Basically

  • 0

I want to create a copy of document in the SharePoint document library.
Basically let us assume there is a template and every user will open the document by clicking on it. I want to create a copy of file user has clicked and open that file for editting.
I have tried using JavaScript Client Object model of SharePoint. But the examples are for manipulating list items but not for document library.
Can any one please point to any sources that I can use to manipulate the files in document library

One restriction being I need to use JavaScript object model or web services to achive this functionality. i.e., NO server side code

Following is the code I got till now

  1. The approach I am planning to use is copy the existing file object
  2. Rename it and
  3. Save it to other document library

Please ignore formatting as I am not able to do it properly and this is under development code

    <script type="text/javascript">
 var clientContext = null;
        var web = null;
        var meetingItems = null;
        var filePath = null;
        var file = null;
        debugger;
        ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");


        function Initialize() {
            clientContext = new SP.ClientContext.get_current();
            web = clientContext.get_web();

            this.list = web.get_lists().getByTitle("Documents");

            clientContext.load(list, 'Title', 'Id');
            var queryStart = "<View>"+ "<Query>"+ "<Where>"+ "<Eq>"+ "<FieldRef Name='Title'/>" + "<Value Type='Text'>"; 
                    var queryEnd = "</Value>"+ "</Eq>"+ "</Where>"+ "</Query>"+ "</View>";

camlQuery = new SP.CamlQuery(); 


queryMeeting = queryStart + 'DevCookbook'+ queryEnd;

camlQuery.set_viewXml(queryMeeting);

meetingItems = list.getItems(camlQuery);
clientContext.load(meetingItems);

            clientContext.executeQueryAsync(Function.createDelegate(this, this.onListLoadSuccess), Function.createDelegate(this, this.onQueryFailed));
        }

        function onListLoadSuccess(sender, args) {
        filePath = meetingItems.get_item(0).get_path();
        file = meetingItems.get_item(0);
        debugger;
        clientContext.load(file);

            clientContext.executeQueryAsync(Function.createDelegate(this, this.onFileLoadSuccess), Function.createDelegate(this, this.onFileFailed));

           // alert("List title : " + this.list.get_title() + "; List ID : " + this.list.get_id());

           // doclist();        
        }
function doclist()
{
var path = file.get_title();
path = meetingItems.get_item(0).get_file().get_title();
}
        function onQueryFailed(sender, args) {
            alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
        }

        function onFileLoadSuccess(sender, args) {
        debugger;
      alert("List title : " + this.list.get_title() + "; List ID : " + this.list.get_id());


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


        </script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:06:30+00:00Added an answer on May 27, 2026 at 1:06 am

    I used copy webservice to do the functionality.
    Approach is combination of Object Model and JavaScript functions

    1. Copy the file from templates library.
    2. Check out file using “CheckoutDocument” function
    3. Add metadata in background
    4. Show edits metadata pop up to user using

      var oDialog = {
      url: “../Library/Forms/Edit.aspx?ID=” + itemID,
      title: “Create a new document”
      };
      SP.UI.ModalDialog.showModalDialog(oDialog)

    5. After user input check in the document
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I want to make a copy of a database, I always create a
I want to copy the content of a word document to another, with replacing
Basically, I want an exact copy of the XML, except I'd like to sort
Basically I want to load a HTML document and using controls such as multiple
i want to create a pdf page where i want to copy some text
I want to create a doc file and copy some of the content to
I have a document library with 4 content types, each having a default template.
I want create a drop shadow around the canvas component in flex. Technically speaking
I want create a excel with Apache POI in java and I must insert
i want create image animation , i have 50 images with png format now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.