SharePoint Alerts - Removing Management Status

This entry is in response to a query raised by a partner on the HP TRIM user forum. I figured other people would be seeing this same behaviour and would like to know how to deal with it. So I spent a bit of time researching, reading and testing until I resolved it.

So, what’s the issue? If you use SharePoint alerts on lists and libraries that have content managed by the integration, you will most likely have seen this behaviour as described below.

In the following example I have configured an immediate SharePoint alert on a document library, to tell me when documents have been added or edited. Some of the documents in the library are managed by HP TRIM.

When I receive an email alert it looks like this:

Most of the alert is taken up by a field called Management Status, which contains some XML. This custom field is used by the integration to determine the state of a list item. In normal use if you add this field to a list you don’t see the actual XML, but a value of ‘Unmanaged’ or ‘Managed’.

The question is, Can you get rid of this unsightly XML from your SharePoint alerts?

Thankfully the answer is yes, although as with many things SharePoint, there is a bit of configuration work involved.

The look and feel of alerts is controlled by XML templates, stored in the SharePoint Hive, at this location:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML

There are two files that need modifying and that need to be kept in sync, but it is important NOT to modify the original files. So, we are going to take copies and modify the copies. Take copies of:

  • alerttemplates.xml
  • alerttemplates_sms.xml

In my case I prepended my copies, so I end up with the following copied files:

  • copyalerttemplates.xml
  • copyalerttemplates_sms.xml

These files are quite large, and actually contain multiple templates in different XML nodes. So, we need to locate the relevant sections for each template, and modify them. I recommend using a proper XML editing tool to do this, as it will make locating and editing the relevant sections much easier. In my case I am using Visual Studio, but I would recommend Notepad++ as a free alternative.

Let’s go ahead and open up the copyalerttemplates.xml, we are looking for the highlighted sections in the XML, these identify the specific templates within the file (Hint – Search for AlertTemplate in the file):

<?xml version="1.0" encoding="utf-8"?>
<!-- If you are customizing alerttemplates.xml or alerttemplates_sms.xml, please ensure you keep them in synchronization in every parts except the format section. -->
<AlertTemplates>
    <AlertTemplate Type="List"  Name="SPAlertTemplateType.GenericList">
        <EventTypes IsVisible="True"/>
        <Format>
<Digest>
    <Header><HTML><![CDATA[<html dir = $Resources:core,PageDirection;>
 <head>
 <base href="]]></HTML><GetVar Name="SiteUrl" URLEncodeAsURL="TRUE" /><HTML><![CDATA[">
<style>
<!--
.headertop1 {
  width: 100%;
}

In this example I’m going to focus on modifying the GenericList and Document Library templates, but you will need to modify all the templates for any content that might be managed and for which you might be generating alerts. For instance, there are also templates for Tasks & Events. Make sure to look at all instances of AlertTemplate and decide which sections you need to modify.

Once you have located a relevant template, you need to locate the Properties node within it. Scroll past or collapse (Depending on your XML editing application) the Format section, Properties follows immediately after it. Within the Properties node there are two ExcludeFields nodes for immediate and digest(Daily & Weekly) alerts. Add the ‘ManagementStatus’ column into the excluded fields list, as in the highlighted example below:

        <Properties>
            <ImmediateNotificationExcludedFields>ID;Author;Editor;ManagementStatus;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;</ImmediateNotificationExcludedFields>
            <DigestNotificationExcludedFields>ID;Author;Editor;ManagementStatus;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;</DigestNotificationExcludedFields>
        </Properties>

Now work your way through the file and repeat this for each relevant AlertTemplate section, again in this example I’m only going to edit the Document Library template as well (Note that I’ve shortened the Format section considerably in the example below):

		    <AlertTemplate Type="List"  Name="SPAlertTemplateType.DocumentLibrary">
        <EventTypes IsVisible="True"/>
        <Format>
<Digest>
    <Header><HTML><![CDATA[<html dir = $Resources:core,PageDirection;>
 <head>
 <base href="]]></HTML><GetVar Name="SiteUrl" URLEncodeAsURL="TRUE" /><HTML><![CDATA[">
<style>
<!--
.headertop1 {
.
.
.
.
        </Format>
        <Properties>
            <ImmediateNotificationExcludedFields>ID;Author;Editor;ManagementStatus;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;</ImmediateNotificationExcludedFields>
            <DigestNotificationExcludedFields>ID;Author;Editor;ManagementStatus;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;</DigestNotificationExcludedFields>
        </Properties>
        <Filters IsVisible="True">
<FilterDefinition>
 <FriendlyName>$Resources:Alerts_anything_filter_begin;$Resources:Alerts_document;$Resources:core,Alerts_anything_filter_end</FriendlyName>
 <ShortName>$Resources:Alerts_anything_filter_shortname;</ShortName>
 <Query>   
   <Neq>

Once you’ve added the ‘ManagementStatus’ field to all the required properties sections, save the file and the repeat the process for the ‘copyalerttemplates_sms.xml’ file too.

The next step is to tell SharePoint to use these modified alert template files instead of the original files. This requires stsadm commands to be run (There are no equivalent PowerShell commands yet).

From a cmd prompt run the following stsadm commands (Replacing http://yoursitecollection/ with your own site collection url):

stsadm -o updatealerttemplates -filename “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\copyalerttemplates.xml” -url http://yoursitecollectionroot/

stsadm -o updatealerttemplates -filename “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\copyalerttemplates.xml” -url http://yoursitecollectionroot/

Then you will need to restart the ‘SharePoint 2010 Timer Service’ from Windows Services on each server in the farm. This forces SharePoint to load the updated version of the template file. You may also need to perform an iisreset on each WFE in the farm, although I've found it has worked without this step.

And that’s it; your alert emails will now be back to normal, sans Management Status XML.