2

I wish to copy documents of one library to another. Here I am using SharePoint App in which I am providing drop-down lists to select documents and then clicking on button I am inserting those drop-down list values into one list.

Here I am inserting data into list because, I want to create a new folder in the destination library.

I have two libraries
1.Source
2.Destination

This Source library will contain many documents those will be listed into App into the various drop-downs and after that, I wish to copy those selected documents into a destination library.
like bellow snaps
enter image description here

enter image description here

NOTE- I'm using SharePoint designer workflow 2010

1

This can be done multiple ways.

Via Server object model.

SPFile sourceFile = web.GetFile("http://basesmcdev2/sites/tester1/tester2/A0805051340558063824.txt");

sourceFile.CopyTo("http://basesmcdev2/sites/tester1/sub1/shared documents/A000345.txt", true);

Via Jquery/SpServices.

function copyItem(){
        var itemurl = "<yoursourcrul>"; //CHANGE THIS
        var dst = "<yourdetsinationurl>"; // CHANGETHIS
        $().SPServices({
            operation: "GetItem",
            Url: itemurl,
            async: false,
            completefunc: function (xData, Status) {
                itemstream = $(xData.responseXML).find("Stream").text();
                       console.log(itemstream);
                itemfields = "";
                $(xData.responseXML).find("FieldInformation").each(function(){
                    itemfields+=$(this).get(0).xml;
                });

            }
        });
        $().SPServices({
            operation: "CopyIntoItems",
            SourceUrl: itemurl,
            async: false,
            DestinationUrls: [dst],
            Stream: itemstream,
            Fields:itemfields,
            completefunc: function (xData, Status) {
                var error = $(xData.responseXML).find("CopyResult").first().attr("ErrorCode");
                       console.log(error);
            }
        });
    }
  • so i can put this code in my App's files here inside app.js,rigth? – Madhav Nov 24 '16 at 9:28
  • yes....and call this method, you can modify method to take sourceurl and destinationurl as parameters... and call this method on button click. – Siddharth Vaghasia Nov 24 '16 at 10:40

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.