Creating Search Alerts in SharePoint 2013

Creating Search Alerts in SharePoint 2013 is a tad different than it was in SharePoint 2010. SharePoint 2010 had a SearchAlert class which allowed you to easily create the alerts. This class had a single dependency on the Web Application using it; there had to be a Search Service Application Proxy attached to the Web Application.

In SharePoint 2013, it is slightly different. The SearchAlert class’ constructor has been marked internal, and although you can access the constructor of the SearchAlert class via reflection, using reflection is unsupported.

The workaround is fairly simple, but it now has a dependency on the Web Application having a User Profile Service Application Proxy. Without the UPSA proxy, creating the alert will fail. Otherwise, this code is mostly gleamed from reflection.

The keys here are setting the AlertTemplate to “OSS.Search” and setting MatchId to Guid.Empty.

2 Comments

  1. Great article. Thank you for sharing your knowledge. But I get the following error message on spAlert.Update(true): List does not exist.The page you selected contains a list that does not exist. It may have been deleted by another user.

Leave a Reply