While testing a database attach migration from SharePoint 2007 to SharePoint 2010 I noticed that alerts were no longer firing off. The test users verified that their alerts did carry over from SharePoint 2007 and was displayed in their alert listing.
I verified that the outgoing email server configuration was correct and that the immediate alert timer job was enabled in SharePoint 2010. I created a new alert on an announcements library and immediately received an email confirming the subscription. This proved that my outgoing email configuration was working as expected.
I proceeded to test the new alert by creating a test announcement item in the list. Within 5 minutes I received the alert as I would expect. So if new alerts are working, why are the ones carried over in the migration not working?
I opened up SharePoint Manager 2010 and started digging. I expanded one of the nodes for a SPWeb object that I knew had user alerts configured. I opened up the alert collection and sure enough, all of the alerts were listed. I looked over the alert properties and everything appeared to be in order.
I am still digging in and researching this issue. I have some test code and some ideas that I am going to try in the next couple days. I will update this post as I progress and hopefully come to a solution.
If you have run into this issue I would love to hear from you. Please either leave a comment or send a message directly to me via the “Contact Me” link in the very upper right hand corner of this site.
Update 7/28/2010: I have had some success getting the alerts to fire off. I have been using a couple of simple command line programs I wrote using C# to test and reset the alerts. I have more testing to do today and hopefully soon I will have reproducible steps on how to resolve this in my QA environment.
Update 2 – 7/28/2010: I figured out the issue. This is a problem not just specific to SharePoint 2010 or caused by the migration. The issue is that the URL for my QA server farm is different than the original URL of the server farm from which the content was migrated. The SPAlert objects are storing a reference to the url of the original site. To fix this issue takes a little bit of patience and coding.
The blog at http://blogs.msdn.com/b/skelley/archive/2007/06/18/alerts.aspx explains the issue and links to a KB article with sample code from Microsoft. (Check out my update post for more information)
Bottom line: If you do a database attach to a web application with a new URL you will have some problems. One being alerts will break. To fix you need to touch each SPAlert object and force it to refresh by change one of the properties to some new value, updating the alert, then changing the value back and updating the alert again. This only solves part of the issue. You must also update the siteurl property of the alert to the proper URL or your emails will link users back to the wrong location.
After chasing this around for a while I have a much better understanding of what happens under the covers. Sad part is I won’t need to use any of this knowledge for my production roll-out because when I do that migration the URLs will not be changing.