Whilst working with a client recently we decided to use the Content Migration system within SharePoint to allow us to create a template site that could then be used as the source for the 88 sites that needed to be created for each of the areas of interest.
Each site had identical set-up with regards to security and the groups involved, the data merely changed by geographical location, with each site representing a postal district. As the custom webparts all triggered from data such as the site title for their geo-location data, this provided us with the best mechanism for creating the structure.
During the UAT period however we did experience one problem that I didnâ€™t expect, This related to task creation and the automatic notifications sent to users. In our template site, we created a standard out of the box task list and turned on the â€˜Notify on Task Assignmentâ€™ option.
This worked as expected in test, but during the migration something happened to the alerts and none of the 88 sites sent alerts when tasks were created.
The first thing I do when task alerts arenâ€™t working is to set-up an â€˜Alert meâ€™ on a list or document library. When this is done you immediately receive notification that this has been done, so this shows that the SMTP is configured correctly. Then creating a new item triggers the second alert (Be aware of the timer delay though, alerts may take up to 5 minutes to be triggered as this runs on a default 5 minute timer. (Which can be changed..))
In this instance, these tests worked ok. So, now knowing that the infrastructure was ok, I started thinking about how SharePoint handles this kind of alert. In alert parlance, these Task alerts are called immediate scheduled alerts, as opposed to the daily round up or journal alerts. When an alert such as this is created, an entry is made in the dbo.ImmedSubscriptions table.
WARNING: Doing any kind of querying into the SQL databases of SharePoint is NOT supported and this was done for investigative purposes only. I would recommend only doing this when all else fails OR, Microsoft tell you to do it!
In my test system, I created a new site collection and then a new tasks list. Initially for this site, task alerts were off so the ImmedSubscriptions table was empty. However after editing the properties of the tasks list and turning on E-mail notifications, the following data appeared in the content-db.
The key areas of information that weâ€™re interested in are shown above, Primarily the Site and Web urls, the list name and most importantly the AlertTemplateName (SPAlertTemplateType.AssignedToNotification) and the filter that applies the alert.
In the case of the sites for my client, this data did not appear for any of the sites created from the Content Migration Package and we can therefore assume that when creating these sites, alerts do NOT get processed in the normal way.
The fix is simple, turn off the alerts and turn them on again, this creates the entry and alerts start working as expected. moving forward, weâ€™ve now created a quick powershell script than turns Alerts off and back on again after the site is created using the SPList object and the EnableAssignToEmail property.