1

I try to find an easy solution for copying a list items with all field values (duplicate a list item) and edit some specific lines at the end.

The script I'm using right now isn't perfect for my needs, because I have to copy every single field one by one and I want a script that does this automatically. E.g. copy list item '2' and edit title to a new one. Not 'copy title, copy entryDate, copy hours, copy... edit title.

        var updateXML = "<Batch OnError='Continue' PreCalc='TRUE'>";
        var index = 1;

        $(xData.responseXML).SPFilterNode("z:row").each(function() {
            var title = $(this).attr("ows_Title");
            var entryDate = $(this).attr("ows_Entry_x0020_Date");
            var hours = $(this).attr("ows_Hours");

            updateXML = updateXML + "<Method ID='" + index++ + "' Cmd='New'>" +
                    "<Field Name='Title' Type='String'>" + title  +  "</Field>" +
                    "<Field Name='Entry_x0020_Date' Type='Date'>" + entryDate +  "</Field>" +
                    "<Field Name='Hours' Type='Number'>" + hours +  "</Field>" +
                    "<Field Name='IssueID' Type='Number'>" + newParentID +  "</Field>" +
                    "</Method>";
         });

        updateXML = updateXML + "</Batch>";
2
  • why are you editing the xml? you could access the field you want to change directly from the list item
    – Gwny
    Nov 19, 2014 at 9:04
  • I also recommend creating a workflow (with "Copy List Item" action) in Sharepoint Designer. Then you can add a "Duplicate" button into the ribbon to make this feature available to the users. To do so you can have a look at ranaictiu-technicalblog.blogspot.fr/2010/06/…
    – AymKdn
    Nov 22, 2014 at 14:38

1 Answer 1

1

I recommend creating custom workflow using SharePoint Designer. In the workflow, use the "Copy List Item" action to copy the item.

Blog article containing full step-by-step instructions can be found here.

0

Your Answer

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

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