3

I want to make a copy of list/document library item when I will clicked on that item/document's name, using OOTB workflow?

  • I don't think you can start a workflow by opening a document. – Erin L Jun 10 '16 at 12:48
  • The workflow can start when the document is created or modified, so what you probably need to do is to create a javascript code that will detect a click event and will create a copy of the list item. Maybe you need to elaborate more on what you are trying to achieve by this and I can help think of a different approach if any – Ahmed Mahmoud Jun 10 '16 at 13:15
  • here i want to create new column n n that column have to store one default value and after clicking on it i want to make copy of same document inside same library/list,here i have created new column in which m storing the url of current item and now what i want to do i s by clicking on this url link value i want to copy that document in same list – sharepoint2013 Jun 13 '16 at 4:29
2

Not possible through OOTB workflow, though you can use SharePoint Designer workflow.Also the workflow triggering has to be done manually or modifying or creating an item. There is no provision for triggering a workflow on clicking of item. You have the option as Set and Create item in Designer workflows through which an item can be created in a list.

1

Either you try with Event receiver or a javascript based approach like CSOM/JSOM. workflow only triggers when an item is added/updated/deleted. So you can have a REST API based code which add/update a list item which can cause workflow to trigger.

0

Note:

in June 2017, Microsoft disabled the use of JavaScript in a Calculated Column

That means given answers may not apply for newer SharePoint versions

For long explanation and work arounds see:
June 13th 2017 Microsoft blocked handling HTML markup in SharePoint calculated fields - how to get the same functionality back


Original answer:

You could do it with code

  • create a new item
  • copy field values from the original item

If you are happy with only activating from a View

You can paste this Formula in a Calculated Column and set the Datatype to Number

="<img style=cursor:pointer src=/_layouts/images/icongo01.GIF onclick=""{"
&"event.stopPropagation();"
&"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();})})}"
&"this.style.display='none';var TR=this;while(TR.tagName!='TR'){TR=TR.parentNode}"
&"TR.style.cursor='wait';cloneItem(TR.id.split(',')[1]);"
&"}"">"

Full explanation at http://www.viewmaster365.com/#/How (including Pros & Cons)

It adds a Clone button to the View, onclick it:

  • Creates a new Item in the current List
  • copies all Fields from the current Item to the New Item (exlcuding Attachments/ContentTypes)
  • redirects the browser to the EditForm of the New Item

It only works in Views.. but does work in SP2010

In SP2013 you can offload the logic to a CSR file; and use it anywhere you want. But you need some more boilerplate code to trigger the uncompressed code:

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();
            })
        })
}

This all works for the list Item, it does not copy Documents

ICC

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.