2

I need to create a workflow that simply duplicates a list item and adds it to the same list. (when item is created). I know that there is the function in SP Designer 2010, but Im not allowed to use this functionality since I should create it with SP Designer 2013 only. Is there a good workaround for that? Best solution would be a web service to do it, but im not that familiar with it. I think this articel leads to the right direction, but there is still something missing and Im not 100 % sure what it is actually doing.

http://mysharepointinsight.blogspot.de/2013/05/using-sharepoint-rest-services-from.html

Can somebody privde me some help?

  • Be careful, your workflow might quickly fill your list with thousands if not millions of copies of the same list item unless you make it understand which item is created by a human and which is already a copy. – Alexey Krasheninnikov May 23 '17 at 4:14
1

If I understood correctly you would like to create the same item via a Workflow in the same list?

Then you can select under Actions -> Create New List Item -> and then just set Title and all you columns to the current item and the field.

No need to work with REST here.

Do not forget to check the box "Run on item created"

  • that would be one solution, but the workflow should be rather generic, since it should be used for several lists :) – Julian Herbold Dec 1 '15 at 14:03
1

Not Workflows but JSOM code

Get the ID of the item you want to clone (in the current context) and execute:

function cloneItem(id) {
    var c = new SP.ClientContext.get_current(),
        l = c.get_web().get_lists().getById(SP.ListOperation.Selection.getSelectedList()),
        i = l.getItemById(id),
        f = l.get_fields(),
        n, e, d, m, v,
        url = _spPageContextInfo.serverRequestPath;
    c.load(i);
    c.load(f);
    c.executeQueryAsync(
        function () {
            n = l.addItem(new SP.ListItemCreationInformation());
            e = f.getEnumerator();
            while (e.moveNext()) {
                d = e.get_current();
                m = d.get_internalName();
                if (!(d.get_readOnlyField() 
                       || d.get_hidden() 
                       || ['Attachments', 'ContentType'].indexOf(m) > -1)
                   ) {
                    v = i.get_item(m);
                    if (v) n.set_item(m, v);
                }
            }
            n.update();
            c.load(n);
            c.executeQueryAsync(function () {
                document.location = url.substr(0, url.lastIndexOf('/')) 
                                     + '/EditForm.aspx?ID=' + n.get_id();
            })
        })
}

SO Answer: Set default values in new controls on custom form

Executes it from a List View:

0

How about using custom workflow action to do this

How to: Build and deploy workflow custom actions https://msdn.microsoft.com/en-us/library/office/jj163911.aspx

Walkthrough: Create a Custom Site Workflow Activity https://msdn.microsoft.com/en-us/library/ee231574.aspx

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.