Social media


            

Thursday, January 2, 2014

SharePoint reminders: Don't forget, always remember! Part 1

Welcome in the new year! As promised, we begin it with an article by Tomasz Głogosz about one of the possible applications of Datapolis Workbox - SharePoint reminders. It was first published in Spanish in the December edition of CompartiMOSS, the magazine of Spanish-speaking SharePoint community. You can also read it on our company website.

Wake up! Wake up! Wake up! - Please no… just ten more minutes! Lots of us talk like that every morning with their alarm clocks. Usually we press the sleep button and after several minutes the clock rings again. But what happen if it does not? In most cases the result is oversleep and being late to work. Now let’s think about a situation when a  friend calls you in a day and asks for help. You say “Call me in the evening, I will help you” and usually forget about it. Unless he or she calls you later you will not remember to help them.
Where else people act like that? In a professional environment of course. It is quite likely that in your workplace you receive automated emails with information about some task to do. But, as you work on other tasks already, you would like to save it for later. Sometimes you will remember about a new task, but in lots of cases you will simply forget about that so it would be the best if someone reminded you later. Especially if you are a boss – you are probably tired of reminding others about their work and would like your IT system to do it. 
In this post I will describe several ways of achieving that using Microsoft SharePoint and its extensions. I will cover differences between them as well as their advantages and disadvantages. I hope that after reading it you will know which method fits your needs.

Environment
At first we need some environment - let it be a SharePoint web site with a simple list. The list contains three columns: Title (of an issue), Assigned to (some employee) and Due date. It looks like this:

Simple SharePoint list with assigned issues

How will the typical scenario look like? We have an issue (task, work item etc.) and we would like to inform a user that he or she has something to do. We would like to keep notifying that person for as long until the work on the issue starts. But what to do when due date approaches? The person who created the issue should be probably informed that something goes wrong. So we need a mechanism that sends an e-mail to the assigned user every day until he or she picks up the task (let’s debate later what does it mean) or, when due date approaches, alarms the user who created an item.

First idea
When you think about notifications in SharePoint the first thing that comes to mind are alerts. From a browser level you can simply set an alert on a library or an item to keep you (or other people) informed about what is going on. Alerts however work only when something happens: an item is added, changed, deleted etc. We will get information when an item is created, but later, if we want to remind a user about his task which remain unchanged, that is not enough. We need something more powerful.

Typical second step
Usually if there is no option to do something in a browser the second step is SharePoint Designer where can create declarative workflows. Let’s try!

The SharePoint Designer workflows may include several activities which are interesting for us, like:

  •          Send Mail, with the possibility to select as recipient Current Item Author and Current Item field
  •          If Activity, which can check and differ values of Current Item fields
  •          Pause activities, one for waiting for some time period and the other for waiting until selected date, which can be  looked up from Current Item

Putting it together gives us the workflow below:

A simple workflow created in SharePoint Designer


The workflow sends an e-mail after we create an issue (great!), waits until due date and notifies the author of the issue that it has not been picked up yet (even greater!). But wait, where is the most important thing – daily reminding?

Unfortunately we can’t do that. In SharePoint 2010 Microsoft removed from SharePoint Designer the Loop activity, the one that we really need for daily reminding. We still can make some workarounds, like putting Pause activity inside If and then, inside that one, other If with other Pause. The workflow waits, checks, waits, checks, etc., but only for the selected number of times. It could fit in some scenarios but in most cases we would need to find some other way.

Big gun
               
The third option, most powerful but also most time consuming, is Visual Studio. To use Visual Studio and develop SharePoint solutions we need a programmer, so the description below was written with programmers in mind – beware!

We can develop custom code for timer jobs that runs in selected time spans. At start we need to have a SharePoint type project (e.g. SharePoint 2013 – Empty project) deployed as a farm solution. Then we can create a class for our timer job which should inherit from SPJobDefinition. Remember to create two constructors: one with parameters for initializing a new instance in your code and one without parameters for SharePoint – it is needed for deserialization. The whole class will look like this:



Next step will be the filling Execute method. We need to open objects like SPSite, SPWeb and SPList – those ones where we store our issues.



Now we can load every issue which waits to be picked up. The best for it will be SPQuery which will load every item where Status equals Assigned and Date is greater than today’s date. For every item we will send an e-mail to Assigned To person with notification.



We should do similar thing for issues that are over due date, but this time we will send e-mails to authors of documents.



We need also a little code for installing and uninstalling the timer job. That code can be started from a farm feature or a farm configuration page.



At last we have our solution. It meets our scenario: reminds people about their issues every day and after due date alerts the author. And it is not very complicated. Is it?

But wait – we have a coded solution (so we need to be a programmer or have one) which contains hard coded data about site, list, mail content etc. If something changes we will need to update the solution and redeploy it. It takes time. Also we do not have anything to configure a solution, install the timer etc. So what should be next?

 To have a full solution you need at least:
  •          Farm feature, for installing/uninstalling timer job
  •          Configuration page (you need to decide where to put it – farm, site?) allowing at least to configure e-mails, site and list.
  •            Some store where you should keep your configuration data

And you need to decide how exactly you would like this to work. You have to remember that our scenario is very simple. Big companies may have very specific policies about such reminders, so you can have lot of work with more complicated scenarios and may need to create custom solutions for different departments. It could take from several hours up to several days. Sounds ridiculous for such a simple task. There should be some simpler method, shouldn’t it?

Other ways
There are plenty of 3rd party solutions for SharePoint - I will show that some of them not only support our scenario but also processes that this scenario is part of, so you can develop much more that only reminders. I will present their advantages and disadvantages, i.e. what you can do with them in context of reminders and what you cannot.

Nintex Workflow claims that it is “Workflow for Everyone,” so let’s check if it is for us too. In our scenario we can use activities similar to SharePoint Designer like Send Notification (i.e. send an e-mail) and Pause for (i.e. Delay) and include as well a loop activity. Now we can send an e-mail and wait until due date or until  the assigned person picks up an issue. The workflows checks if one of those conditions is met. Then it can move forward or send info to the author (i.e. when an issue is not picked up and due date is passed). Our workflow will look like this:





As you can see we accomplished our task. For constructing such a workflow you need less than an hour.  Great! Isn’t it? Mostly. But what happens if we would like this workflow to manage our issue process further? The workflow doesn’t know when an issue is picked up. What if we would like to send an e-mail to the author of the issue (in many companies we need such things)? Or if we would like to send back an issue to the author to update it? Or if after an issue is completed the author decides to send it back to us? We would need to reassign the issue and always send reminders for the assigned person and also for the author. Like I mentioned, it is a rather complicated task.


TO BE CONTINUED

Tomasz Głogosz is Datapolis Workbox project manager and senior .NET architect.