sharepoint alerts: how to repair them after a web app move
this past weekend we had a sharepoint farm where we needed to detach the databases and reattach them to a different web application.
this can break a lot of things, dr watson has a good list of some of them.
i'm going to focus on alerts and how to fix them (yep they break)
first of all there is a nice chunk of sample code to help fix this but its incomplete:
https://support.microsoft.com/default.aspx?scid=kb;en-us;936759
here's the piece of code we care about:
|
basically all they're doing is changing a value in the alert, updating it, and then putting the value back to what it was.
what this essentially does is update a hard coded value called siteurl in the alerts table.
this works, kinda
the alerts will be sent out but the contents of the alerts will be referencing old links
that's bad news.
so how do we fix it?
well lets start with the content database tables that deal with alerts:
immedsubscriptions | contains immediate alerts |
schedsubscriptions | contains all other alerts (daily, weekly, etc) |
ok so lets have a look there
select top 20 * from immedsubscriptionsselect top 20 * from schedsubscriptions |
hmmm the column called properties seems to have some hard coded urls...
(click to enlarge)
pretty strange since there is another field in that table called siteurl
(fyi updating the siteurl in these tables is what the microsoft supplied sample code fixes)...
so why not just use that siteurl as the url in properties instead of hard coding it?
no clue but they probably had a good reason.
anyways now we have to see whats in that bag... the property bag.
how did i know to look there? (i'm sleeping with the property bag lady)
just kidding, it took a bit of tinkering considering that the properties field is not directly writable from an alerts object:
SPAlert Properties
Properties Gets the properties of the alert.
https://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spalert_properties.aspx
if you want to set the alert, you must use the property bag.
this concludes how to fix alerts after a webapp move. i hope you like.
Comments
Anonymous
June 18, 2007
PingBack from http://blogs.msdn.com/mikewat/archive/2007/06/18/moving-databases-between-web-apps.aspxAnonymous
June 18, 2007
PingAnonymous
March 10, 2009
Migration from SharePoint 2003 to 2007Anonymous
March 10, 2009
Migration from SharePoint 2003 to 2007Anonymous
October 18, 2011
I've created a product that can migrate alerts automagically. It currently works, and you can find out more about it here. sharepointalert.blogspot.comAnonymous
December 05, 2011
UPDATE dbo.ImmedSubscriptions SET SiteUrl = 'http://new-url.com'; UPDATE dbo.SchedSubscriptions SET SiteUrl = 'http://new-url.com'; Unsupported, yes. Effective, yes.Anonymous
February 15, 2012
Jordan - What about the Properties column? I did this ( UPDATE [SchedSubscriptions] SET [Properties] = REPLACE ([Properties] , 'http://OldUrl', 'http://NewUrl') WHERE [Properties] LIKE '%http://OldUrl%' ) but they do not seem to be working yet.