User Alerts and Views to Send Selective Emails

In my day to day work I meet a lot of SharePoint users, who want to use the product to make themselves and their teams lives easier. Any quick browsing of SharePoint articles will reveal that the SharePoint End User is empowered as never before with the new features in 2010, and the improvements in SharePoint Designer 2010.

Alas, there are plenty of organisations that don't allow SharePoint Designer to be used. With that in mind, I'm writing today about a nice little feature I used to meet some client needs. The example here is for training request, though the real world requirement was a little different.

Consider this user brief; "I'd like users to enter a training request into SharePoint. Depending on which Department the user works in, a notification email will be sent to the manager for that Department."

It turns out that this is achieveable just creating a few custom views, and alerts on a custom list. No coding, no SharePoint Designer, no IT Involvement. All because you can set Alerts on particular Views.

So, we start with a custom list like this one;

Custom List

You can see the list in more detail here. All I've done is rename the Title field to be Course Title, and the Created By to be Requested By. In the real world you might have a list of courses pre-defined so you'd create a Choice column or Lookup column for the user to choose.

Custom List Columns

I've also added my own choice column of 'Requesting Department' that the user will fill in when they create a request;

Column Details

You can see for this example I've added three example departments, IT, HR, and Accounting.

This will be the list that Training Requests go into. Now we have to get things ready so our different department heads will get their emails. We do this initially by creating a View of our List from the ribbon;

Create SharePoint View

We create a view based on the existing AllItems View, as that saves us some typing.

Create View from Existing View

Our first new view will be called "IT Requests". Notice we create a Public View, order it by Modified Date (so the latest items are always at the top), and the important bit is we add a filter on there to only show items in this new view where Requesting Department is IT.

Create IT View

Once the first view is created when we create our next views we can base them on the IT Requests View we just created.

Create Next View

Then all we need to change is the name of each new view, and the Department value in the filter;

Create Next View Filter

I'll leave the last View to your imagination, as it's basically the same as the other two...

So, I now have three custom views on my training Request list. Each custom view shows only the items from a specific department and nothing else.

I can now go ahead and create an alert, which you'll be able to do from the Ribbon over the list;

Set Alert

You've probably created Alerts before, but if not, you simply need to know that they are used to notify people of changes to list items. The screenshot below shows the options available in that you can select to be notified on all changes, or just the changes of others, and select whether you are notified immediately or have a daily or weekly digest instead. You can also nominate others for the email, not just yourself...

Set Alert On List View

So we create an alert as above, and our IT Manager will be emailed on a daily basis whenever new requests are added to the list, but only those that are shown in the IT Requests view. This is the really neat bit about Alerts - you can subscribe them to specific Views and therefore they become much more powerful in that you send send alerts for specific filters and conditions (of the view). This is true in SharePoint 2007 as well as 2010 by the way.

We repeat the above to create Alerts for the HR and Accounting views with different managers specified.

Creating a new request in the list looks like the screenshot below. In the real world you might want to capture more information;

New Training Request

At the end of the day, the specified IT Manager will get a digest of all training requests by folk in IT. The course title and name are visible in the email. If I'd added a few more columns the data would also be shown in here, in perhaps a prettier way, but this is a simple example!

Alert Email Example

There we have it. Code free solution to selectively email managers of different departments. All because of the cool feature that Alerts can be subscribed to different views. Nice.

Disclaimer: The software, source code and guidance on this website is provided "AS IS"
with no warranties of any kind. The entire risk arising out of the use or
performance of the software and source code is with you.

Any views expressed in this blog are those of the individual and may not necessarily reflect the views of any organization the individual may be affiliated with.