Quick Tip: Adding Documents from Document Libraries to a Quick Deploy job

The content deployment jobs within SharePoint allow content from a source location to a distributed out to another location this could be another Site Collection\Web Application or even another farm. Jobs can be configured for paths, these jobs run at a specified time to deploy all the content to the site or just new and modified content, this is usually scheduled at a period of reduced activity on the site, such as at night, to limit resource utilisation. Additionally out of the box when a content deployment path is created a specific type of job is created called the Quick Deploy job, when configured this will run on a specified interval and allows for important content to be deployed outside of the normal schedule. The Quick Deploy job will look for documents that have been specified by a user within the UI and then deploy content the next time it runs. This allows for content that has been changed to be pushed to the destination site the next time the quick deploy runs.

A problem that has been encountered is that the UI only supports the deployment of Publishing Pages in the pages library. In a majority of cases this is probably what you want to achieve because this is where you would expect people to be modifying content such as a change to the corporate vision.

You can see an example of this feature in the below image

image 

We have found that some of our customers are not using the publishing pages solely for adding this sort of priority message to their sites. Some customers want to use the quick deploy feature to deploy documents within document libraries for content such as urgent memos that need to be deployed immediately.

Within the standard UI this not supported however there is a Class Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob that allows you to add any content to the Quick Deploy Job.

With this in mind I created a feature that supports adding documents in a Document Library to the quick deployment through the UI. Below you can see a standard document that is in a site has the feature enabled. The Add to Quick Deploy will allow the document to be added to the next Quick Deploy run.

image

The below class provides the functionality to add the item to the Quick Deploy

public class QuickDelpoyTest
{
public void QuickDeployment(string siteUrl, string webUrl, string itemUrl)
{
//Add Deployment object

        using (SPWeb web = new SPSite(siteUrl).OpenWeb(webUrl))
{
web.AllowUnsafeUpdates = true;
ContentDeploymentJob.AddQuickDeployObject(web, Microsoft.SharePoint.Deployment.SPDeploymentObjectType.ListItem, itemUrl);
web.AllowUnsafeUpdates = false;
web.Update();
}

    }
}

The following code is from a code behind file that is linked to an ASPX page that call the above class

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
QuickDelpoyTest quickdep = new QuickDelpoyTest();

        string siteUrl = Request["SiteUrl"];
string webUrl = SPContext.Current.Web.Url;
string listUrl = Request["listUrl"];
string itemUrl = Request["ItemUrl"];

        webUrl = webUrl.Remove(0, siteUrl.Length);

        quickdep.QuickDeployment(siteUrl, webUrl, itemUrl);

        Response.Redirect(siteUrl + webUrl + listUrl);
}
}

The elements file below calls the ASPX page with the appropriate variables and add the “Add to Quick Deploy” drop down menu

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
<CustomAction Id="F7BBAD5F-7A57-4337-BBDB-BDFC85F5F51F"
RegistrationType="ContentType"
RegistrationId="0x0101"
Location="EditControlBlock"
Title="Add to Quick Deploy">
<UrlAction Url="/_layouts/QuickDeploy/quickdeploydoc.aspx?ItemUrl={ItemUrl}
&amp;ItemId={ItemId}&amp;SiteUrl={SiteUrl}"/>
</CustomAction>
</Elements>

There is currently an issue with passing the ListUrl however this only effect the post back to the site and not the functionality of the feature.

I hope you find this information useful and helps you if you deliver the required functionality.

This article was published by

Pete Mellish

Consultant

Microsoft Consulting Services UK

Peter.Mellish@Microsoft.Com

Bio Page

n643410622_3725145_8256