Site icon @WonderLaura

Click to Copy List Item to New

Often times, you have a SharePoint list item with all of the fields filled in, and want to simply copy that item to create a new one.  One way to go about it would be to put all of the columns in a datasheet view, and copy an entire row to another one, but that’s not always the most feasible solution.  In this post, I’ll show you another method, how to create a button on a list item which will “copy to new” and then automatically bring up the new item to edit.  This can be done in both SharePoint 2007 and 2010, but my example will be 2010.

Main components to make this work:

  • A SharePoint Designer workflow to copy the list item
  • A custom data view web part for a new list item
  • A custom button that runs the workflow and navigates you to the DVWP.
  1. Create a SharePoint Designer Workflow which can be manually started.  There will be one action: Create List Item
  2. Pick the same name as the current list.  You may want one of the fields to be unique when they create a new request, so you can leave it out of this list of fields.  Add all the different fields on this screen using the Add button, giving them each the same value as the current list item.
  3. Publish the workflow. (I’m naming my workflow “Copy Request” because I’m copying a help desk request.
  4. In SharePoint Designer, click Lists and Libraries on the left, and click the name of the list.  In this case, it’s Request Log.
  5. In the Forms section on the right, click NEW.  Fill the screen in as so, and click OK.
  6. Now, in the forms section, click the name of CustomEdit.aspx to open it.
  7. Hide the existing form web part that’s on the page, we’re not going to use it.  In the web part tab in the ribbon go to properties, then in layout choose Hidden.
  8. At the bottom of the page, click in the spot (at the very bottom of the other web part), to insert a new one.  Click the Insert tab in the ribbon, click the Data View drop-down, and choose Empty Data View.
  9. Click in the middle of this new web part to select a data source, and choose that same list you’re in, in this case, the Request Log.
  10. Use the CTRL key to select multiple fields that you’ll want in the form to be filled out, and click Insert Selected Fields As… and choose Single Item Form.
  11. Filter the data view web part by Created By is equal to [Current User]
  12. Sort the data view web part by Created (descending).  Because of our filter and sort, when users go to this page, it will automatically show them the last item that they just created, in edit mode.
  13. After users have created this duplicate item and clicked SAVE, where do you want them to be directed to?  By default, the Save button will save but not take you away from the page.  Right-click the Save button on this custom form, and choose Form Actions.
  14. After Commit, add Navigate to Page.  Click Settings on the right, and pick which page you want them to be directed to after saving.  After this, I usually have to go into the code and fix the hyperlink because it doesn’t work.  Just start with making it absolute and it’ll work like a charm.
  15. Now, we just need a button that, when clicked will run the workflow to copy the item and then take us to this page.
  16. Go back to the list you’re working on, click the drop-down box on any of the existing items in the list, and click Workflows.
  17. Right-click on the name of the workflow that you just created, and Copy Hyperlink.  This is the link to run the workflow, so paste it into Notepad so we can tweak it.  After the &Source, clear that out and paste in the URL of the CustomEdit.aspx form that you just created. Here’s an example:http://site/_layouts/IniWrkflIP.aspx?List={39dd263a-7b94-4d9b-86b7-a17b64498f9c}&ID=9&TemplateID={69c96028-e504-4317-8e2f-fd319c4cf669}&Source=/site/Lists/RequestLog/CustomEdit.aspx
  18. See the ID=9 that I highlighted in red?  That’s the ID of the item that you’re copying, which will need to vary according to which list item we’re copying.
  19. Back in SharePoint Designer in your list, click on the right side of the screen, putting your cursor INSIDE the Custom Actions section.
  20. Don’t click the New button here in the Custom Actions section, but look up in the ribbon and click the Custom Action drop-down box.  This lets you pick where you want the button to be, such as on the display form or list item menu.
  21. Call the custom action “Copy This”, and use the Navigate to URL option, and paste your customized URL you created at step 15.  In the ID= part, though, you have to replace the actual ID number with {ItemId}, and click OK.

Done.  Now click on an existing item in your list, and click on the “Copy This” button that you just created.  Click Start, and you’ll be taken to the Edit page of the item that you just created as a copy of the other item.  Make any needed changes and click Save.  Done.

This solution works in SharePoint 2007 and WSS 3.0 in addition to 2010.  Just in 2007 you don’t have the easy Custom Action button and you’d have to manually create the hyperlink instead, such as in a data view web part.

7/25/2014 update:  I wrote a new post showing another way to do this, which is slightly similar

Exit mobile version