Alert Template Format

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Windows SharePoint Services 3.0 includes a set of predefined alert templates. These alert templates are stored in Alerttemplates.xml. Alerttemplates.xml defines the format, contents, and properties used to create alert messages from each list type A developer can customize alerts by modifying a copy of Alerttemplates.xml and then loading the customized alert templates by using the command stsadm -o updatealerttemplates.

Note

Do not modify Alerttemplates.xml. Doing so may result in loss of functionality when upgrading or installing service packs.

For a listing of the predefined alert templates, see Predefined Alert Templates.

Alert Templates Schema

Alert templates have the following format:

<AlertTemplates>
  <AlertTemplate Type="List" Default="True" Name ="Default Template">
  </AlertTemplate>
  <AlertTemplate Type="List" Name="SPAlertTemplateType.GenericList">
    <EventTypes IsVisible="True"/>
    <Format>
    </Format>
    <Properties>
    </Properties>
    <Filters>
      <FilterDefinition>
      </FilterDefinition>
    </Filters>
  </AlertTemplate>
</AlertTemplates>

Table 1. Alert template attributes

Attribute

Description

Name

The name of the template. Searching on the template names provides an easy way to locate a particular template.

Type

The type attribute can be set to List, Item, or Custom.

Default

Default = "True" sets the default alert template.

Filters

If IsVisible = "True", the filter fields are displayed when creating the alert.

Filter Definitions

Define a filter (query).

Format

Formatting of the e-mail message is defined in the Format element.

Fields

Specify which fields to render in the alert email.

Filters and Filter Definitions Elements

Filters enable you to create new triggers for an event such as "the priority of a task has changed". To modify existing filters or create additional filters, modify the FilterDefinition element of the appropriate template. Define the query element inside the filter by using Collaborative Application Markup Language (CAML).

The following query creates an alert event if the event date, end date, or location changes.

<FilterDefinition>
  <FriendlyName>$Resources:Alerts_4_filter;</FriendlyName>
  <ShortName>$Resources:Alerts_4_filter_shortname;</ShortName>
  <Query>
  <Or>
    <Or>
      <Neq><FieldRef name="EventDate/New"/>
        <FieldRef name="EventDate/Old"/>
      </Neq>
      <Neq>
        <FieldRef name="EndDate/New"/>
        <FieldRef name="EndDate/Old"/>
      </Neq>
    </Or>
      <Neq>
        <FieldRef name="Location/New"/>
        <FieldRef name="Location/Old"/>
      </Neq>
    </Or>
  </Query>
</FilterDefinition>

Resource variables listed in AlertTemplates.xml, such as $Resources:Alerts_anything_filter_shortname, can be found in core.resx which is located in local_drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Resources.

Note

The Query element in the Alerts schema contains no Where element.

For more information about CAML query schema, see Query Schema.

Format Element

Use the Format element of an alert template to modify the look of the alert message. You can also customize the formatting of the alert message by using embedded styles.

<Format>
  <Digest> - digest format
    <Subject>
    </Subject>
    <Header>
    </Header>
    <HeaderFieldsHeader>
    </HeaderFieldsHeader>
    <HeaderFields>
    </HeaderFields>
    <HeaderFieldsFooter>
    </HeaderFieldsFooter>
    <RowHeader>
    </RowHeader>
    <RowFields>
    </RowFields>
    <RowFooter>
    </RowFooter>
    <Footer>
    </Footer>
  </Digest>
  <Immediate>
    <Subject>
    </Subject>
    <Header>
    </Header>
    <Fields>
    </Fields>
    <Footer>
  </Footer>
  </Immediate>
</Format>

Row Header Element

Each row’s header row refers to each item level change in the digest notification.

Subject Element

The subject of the email.

Fields Element

The Fields element specifies the fields to be rendered in the e-mail message. For example, you can specify <GetVar Name="NewValue#{Field}"> inside the Fields section. You can see more examples in AlertTemplates.xml.

CAML will go over all the fields and render this part of the template. The field itself should be referenced using <GetVar Name=”OldValue#{Field}” /> or <GetVar Name=”NewValue#{Field}” />

To exclude some fields from being rendered in the e-mail message, you should include them in the DigestNotificationExcludedFields and ImmediateNotificationExcludedFields sections. DigestNotificationExcludedFields and ImmediateNotificationExcludedFields give you the flexibility to render different fields for immediate alerts and summary (digest) alerts.

Properties Element

The Properties element allows you to include or exclude fields from the list that would be rendered in the e-mail message and for specifying alert handlers. The example below demonstrates how to exclude fields for both the immediate and summary (digest) alerts.

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

See Also

Reference

IAlertNotifyHandler

Concepts

Query Schema

Alerts in Windows SharePoint Services