Pages

Friday, December 23, 2011

Copying a SharePoint 2010 Web Part Page Including Web Parts

There is a lot of talk about copying a SharePoint 2010 web part page in a page library in SharePoint discussion forums and blogs. We will discuss the available options here.

Copying Pages with No Web Parts
The OOB options that are available to copy a page that has no web parts are discussed below. These options only work with ARTICLE PAGES. If you try to copy a page that has web parts using any of these methods, they will be removed from the target page.

  1. Download a Page: To download a page, go to the pages library and from the page drop-down menu, select Send To –> Download a Copy. Save the page to your local hard disk, rename the page, and upload it. The content will stay as-is in the uploaded page.

    imageimage
  2. Copy the page: This option copies a page from the Pages library to another library in your SharePoint site. Copying a page to the source library is not supported. To use this option, you will need to go to “Manage Content and Structure” option from Site Actions menu, select the “Pages” library, right click on the page drop-down, and select “Copy”. In the “Copy” webpage dialog, select the desired library where you want to copy your page e.g., “Temp Page Library” and select “OK”. When this operation is complete, you will be redirected to the target library. You can rename the page by select “Edit Properties” option from the menu, and move the page back to the “Pages” library.

    image  image image image image image
    image image

Alright, so how do I copy a page with web part(s) without losing it?
That’s a great question and the answer is “you cannot!”. Just kidding Smile. The only option that worked for me was “Copy a list item” workflow using SharePoint Designer. I previously tried this in a custom list and wanted to give it a shot and see if it works for Pages library and it worked! I am writing the steps for SharePoint 2010 using SharePoint Designer 2010.

  1. Open SharePoint Designer 2010 and open your site.

    image image
  2. Select “Workflow” from the “Site Object”s pane and select “List Workflow –> Pages”. Name the workflow “Copy Page Workflow” and write a description for it. Select “OK”. The workflow will be created and will be ready for configuration. Select “Action” from the ribbon and select “Copy List Item” from the menu.

    image image image
    image image
  3. Select “Wofklow Settings” icon from the ribbon. In the “Workflow Settings” screen, select “Allow this workflow to be manually started” checkbox. Select “Edit workflow” link to go to the workflow screen.

    image image
    image
  4. Now we have to configure the source list and the target list.  Select the first “this list” in the workflow step and in the “Choose List Item” dialog, select “Current Item”. Select the next “this list” link and select “Pages” from the drop-down.  Select “Save” and then select “Publish”. The workflow will be published. That’s it! Close SharePoint Designer 2010 and let’s go to the “Pages” library.

     imageimage image image image image
  5. I have a sample web part page in the pages library that is created using the “(Welcome Page” Blank Web Part page” template. In the web part page, I have added a “Content Editor Web Part” and an “Image Viewer” web part. I configured the image viewer web part to display the Google image. Go to the “Pages” library, select a web part page and select “Wokflows” from the menu. Select “Copy Page Workflow” from the list of workfows. Select “Start” from the next page and wait until the process is finished.

    image image image image image image
  6. You will be redirected to the “Pages” library and you will see the copy of the web part having date and time appended. Select the page and you will see the page with the web parts. The copy operation through workflow kept all the web parts of the page!

    image image
So Why can’t I Copy a Web Part Page Using OOB Options?
Well, the answer is SharePoint content pages are stored in SharePoint content database. Everything that is on the content page including webparts is also stored in the database with references. When you copy a page using OOB options, these references are not updated and hence we see a blank web part page. If you are interested to see how SharePoint stores these references, open the content database where your site is stored in SQL Server Management Studio, and look for “dbo.AllWebParts” table. This table stores everything related to web parts in a site including the page that it belongs to (tp_pageUrlID), web part order (tp_PartOrder), and the zone in the ASPX page (tp_ZoneID).

image
If you have time, you can explore more about tables that exist in SharePoint content databases. It will be very interesting! Smile

1 comment:

  1. I get an error if I try to copy a page using your method, to a library other than Pages.

    ReplyDelete