Overview

It is possible to copy a site from a BrightWork site collection to another BrightWork site collection. The Copy Site Across Site Collections feature is used to do this. It is especially useful for copying templates. It is also useful when copying projects, minus any user assignments.

Copy sites using either a Cmdlet or by calling a Web Service. Both approaches will copy the same content from one site collection to another. See the Copy Site Details section for more details on what is included and excluded in a site copy.


Cmdlet

A Cmdlet is a SharePoint PowerShell command-line action. A SharePoint Administrator logged into the SharePoint Server can run a Cmdlet. Permissions required are described below.

Syntax

Copy-BWSiteToAnotherSiteCollection

-SourceSite "<URL as a String>"
-TargetParentSite "<URL as a String>"
-SiteName "<String>"
[-Verbose]

Steps

To run the Cmdlet, as a SharePoint administrator logged into the SharePoint Server, follow these instructions:

  1. Right-click on the SharePoint 2013 Management Shell and select Run as administrator.

  2. Run this command using appropriate values:

    Copy-BWSiteToAnotherSiteCollection -Verbose -SourceSite "<Source Site URL>" -TargetParentSite "<Target Parent Site URL>" -SiteName "<Target Site URL Name>"

    • -SourceSite: references the site you wish to copy. This parameter is required.
    • -TargetParentSite: references the site in the site collection hierarchy to copy the site to. This is usually a Projects Area or Project Office. This parameter is required.
    • -SiteName: is the name of the new site as it is to appear in the URL. See below for an example. This parameter is required.
    • -Verbose: Outputs details on the copy as they occur. This parameter is optional.

Example

Copy-BWSiteToAnotherSiteCollection -SourceSite "https://myserver/sites/dev/templates/standard" -TargetParentSite "https://myserver/sites/test/templates"  -SiteName "newstandard" -Verbose 

In this example, a site in a 'dev' site collection's 'Templates' area and named 'standard' is copied to a 'test' site collection's 'Templates' area and named 'newstandard'.


Web Service

BrightWork provides a Web Service that can be used to call the copy site across site collections feature. This allows workflows, such as SharePoint 2013 or Nintex Workflow, to call the feature from the target site collection. A custom web part such as a Content Editor web part can also call the feature.

Calling the Web Service from a Content Editor web part

The Content Editor web part is a useful way of adding HTML and JavaScript to a SharePoint page. In this sample we use a Content Editor web part to prompt for the parameters needed and to then call the Web Service.

  1. First, download the sample Content Editor web part as a .DWP file or as a .ZIP file. This sample contains code to call the Web Service.
  2. Upload the web part to a web part page and save the page. The web part page can be anywhere within the same SharePoint Web Application, but normally it would be either on the target or source site collections.
  3. If you want to modify the defaults, select the Edit Source action on the Content Editor web part and modify the code.
ContentEditorCSASCWebPart

Calling the Web Service from Nintex Workflow

There are many approaches possible when calling a web service from Nintex. These three steps illustrate a simple approach when calling the Web Service and is intended as a starting point for your own custom workflow.

Here are the three steps as they would appear in Nintex Workflow:

NintexWF_CSASCOverview

Step 1: Get the Context

To create a site you must get the server's request form digest value as the value of the X-RequestDigest header. You can retrieve this value from the /_api/contextinfo end point by extracting the value of the d:FormDigestValue node in the XML. In Nintex Workflow this means:

  1. Add a Web request workflow action from the connectors list.
  2. The URL to enter is a combination of your target parent site collection URL and the following web service call: /_api/contextinfo
  3. Add the account details to access the web service in the Username and Password fields and also select POST.
  4. Set Content type to application/x-www-form-urlencoded
  5. Set the Store result in to a Multiple lines of text Variable (here called ContextInfo).
NintexWF_CSASCContext

Step 2: Get the Form Digest

  1. Add a Query XML workflow action from the connectors list.
  2. Set the XML source to XML.
  3. Set the XML value to {WorkflowVariable:ContextInfo} using the Insert Reference.
  4. Set the Output 1 Process using value to XPath and the value to //*[local-name()="FormDigestValue"]
  5. Set the Return results as to Text.
  6. set the Store result in value to a Single line of text Variable (here called FormDigest).
NintexWF_CSASCFormDigest

Step 3: Call the Web Service

  1. Add a Call request workflow action from the connectors list.
  2. The URL to enter is a combination of your site collection URL and the following web service call: /_vti_bin/BrightWork.svc/CopyBWSiteFromAnotherSiteCollection
  3. Add the account details to access the web service in the Username and Password fields and also select POST.
  4. Set Content type to application/json.
  5. Expand the Add header section.
    1. Set Name to x-RequestDigest (use this actual name)
    2. Set Value to the xRequestDigest Workflow Variable (use this actual value)
  6. In the large text box, enter the parameters. See format in example below. In this example, a site named 'standard' is copied from 'dev' to 'test'. The new site is then named 'newstandard':
    {
     "sourceSite": "https://myserver/sites/dev/templates/standard", 
     "targetParentSite": "https://myserver/sites/test/templates", 
     "siteName": "newstandard" 
    }   
NintexWF_CSASCWebService


Permissions Required

Permissions required differ depending on whether the Cmdlet or the Web Service is being used to copy the site.

Quick Version

Permission Levels are a quick way of assigning a collection of permissions to users. The recommended Permissions Levels are:

  • Source Site
    • Full Control Permission Level to the site.
    • Read Permission Level to the BrightWork Reporter Library at the root of the site collection.
  • Target Parent Site
    • Full Control Permission Level to the site.
    • Edit Permission Level to the BrightWork Reporter Library at the root of the site collection.

It might be not permited in your organization to grant this high Permission Level to users of this feature. In which case the next section will explain the specific permissions that are required.

Specific Permissions Required

Permission Levels are made up of Permissions. You can also assign individual Permissions to users, or create your own Permissions Levels.

The following sections outline the Permissions Levels and Permissions needed in each scenario.

Cmdlet Permissions

The Cmdlet is run on the SharePoint Server so a SharePoint Administrator must run the Cmdlet. It is likely that this account will have the correct permissions to run the site copy. If not then here are the recommended permissions.

Source Site

  • Copying a Template site from the Templates Area
    • Read Permission Level to the template site.
    • Read Permission Level to the BrightWork Reporter Library at the root of the site collection.
  • Copying a Project site
    • Read Permission Level to the project site
    • Manage Web Site Permission to the project site.
    • Read Permission Level to the BrightWork Reporter Library at the root of the site collection.

Target Parent Site

  • Copying a site to the Templates Area or a location in the Projects Area hierarchy
    • Read Permission Level to the Templates Area or target parent site.
    • Create Subsites Permission to the Templates Area or target parent site.
    • The following are required to support Unique Permissions when copying a site:
      • Add and Customize Pages Permission to the Templates Area or target parent site.
      • Add Items Permission to the Templates Area or target parent site.
      • Browse Directories Permission to the Templates Area or target parent site.
      • Edit Items Permission to the Templates Area or target parent site.
      • Enumerate Permissions Permission to the Templates Area or target parent site.
      • Manage Lists Permission to the Templates Area or target parent site.

Web Service Permissions

Calling the Web Service from a web part or workflow needs the following permissions.

Source Site

  • Copying a Template site from the Templates Area
    • Read Permission Level to the template site.
    • Read Permission Level to the BrightWork Reporter Library at the root of the site collection.
  • Copying a Project site
    • Read Permission Level to the project site
    • Manage Web Site Permission to the project site.
    • Read Permission Level to the BrightWork Reporter Library at the root of the site collection.

Target Parent Site

  • Copying a site to the Templates Area or a location in the Projects Area hierarchy
    • Read Permission Level to the Templates Area or target parent site.
    • Create Subsites Permission to the Templates Area or target parent site.
    • The following are required to support Unique Permissions when copying a site:
      • Add and Customize Pages Permission to the Templates Area or target parent site.
      • Add Items Permission to the Templates Area or target parent site.
      • Browse Directories Permission to the Templates Area or target parent site.
      • Edit Items Permission to the Templates Area or target parent site.
      • Enumerate Permissions Permission to the Templates Area or target parent site.
      • Manage Lists Permission to the Templates Area or target parent site.
      • Manage Web Site Permission to the Templates Area or target parent site


Copy Site Details

Any errors or warnings generated during the copy process are written to the Site Provisioning Log in the target site.

What is Copied to the Target Site

  • The site is copied as it exists in the source site. This includes the site's Title and Description.
  • All reports used in the source site are copied if they do not already exist in the target site collection. So, new reports referenced by BrightWork Reporter or Project Metrics are copied into the target site collection automatically.

What is NOT Copied to the Target Site

  • Anything that is not copied when copying a BrightWork site.
  • User Assignments: users assigned to items in the source site will not be assigned to the copied items in the target site.
  • Permissions: permissions set on the source side are not copied to the target site.
  • Site Context Only: only elements of the source site that are fully contained within the source site are copied. The exception to this are BrightWork Reports referenced to in the BrightWork Reporter Library (see above). So, if a source site is using elements from another site, e.g. a Site Column of type Lookup, then these elements will not work as expected in the copied site.
  • Sites copied between site collections in different web applications may not copy as expected. This can be because of features differences in each web application. Copying sites between Web Applications is possible but is not supported behavior.
  • Managed Metadata columns cause Sorry, something went wrong errors and are not supported. To fix this issue after a copy, access the List Settings from the Site Contents page. Then delete the Managed Metadata column. It can be re-added again at this point and the list will open.
  • Enhanced relationship behavior: Lookup columns with Enhanced relationship behavior are not supported and can lead to other knock-on errors in the list.

Was this article useful?

Back to Top