Subscribe to a custom alert template from a workflow

Is it possible to create an Alert Template and then during a workflow when I subscribe a user to the alert set the template?

SPAlert spAlert = spWeb.Alerts.Add();
spAlert.AlertType = SPAlertType.List;
spAlert.AlertFrequency = SPAlertFrequency.Immediate;
spAlert.EventType = SPEventType.All;
spAlert.List = spList;
spAlert.User = spUser;
spAlert.Update();

What would I specify to select my custom template?

 Thanks

Wes

Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Matthew McBride

    Once you create an alert template, you should be able to retrieve it and set it for the SPAlert object. Use the Microsoft.SharePoint.SPAlertTemplateCollection(SPWebService wssService) constructor to return the list of SPAlertTemplates for the web application, then get an instance of the one you are looking for and set the SPAlert.AlertTemplate property to the SPAlertTemplate.

    David Fisher
    Software Engineer
    SharePoint Solutions
Please sign in to leave a comment.