Creating a Timed Workflow in SharePoint 2010
By Les Williams
Yes, yes, I know. There is no timed workflow in SharePoint. The only ones listed are manual, new item, or changed item. True, those are the only ones listed. However, there is one other. It goes by the name Expiration Policy.
I do not do blogs. In this case, I will make an exception. It took some time and lots of searching to find all the pieces of this puzzle. I will never be able to remember it all. This blog is my memory. If it helps someone else along the way, so much the better.
What is the Expiration Policy? How do you get to it? Go to any content type, list, or library and look for Information management policy settings.
Click on the link and several items are listed:
Imagine my surprise with the “Enable Barcodes.” Barcodes are just a font after all. The one we want is “Enable Retention.”
Note the sentence: Items will not expire until a stage is added. This is the expiration policy. There should be no confusion. Very obvious, right? Click the link to add a retention stage:
Here is how you specify the expiration of a document or an item. The default is to use the create date and add whatever years to that. At the end of that time, the action is to move the document into the “site collection” recycle bin. This seems to be the case whether it is associated with a content type or a library. Normally, the selection is for content type. You can change this for a library or list by clicking on “Change Source” in the library:
This will, of course, break any retention rule on the content types in the library if they exist. Maybe you need something different for this library. The choice is yours. Still, the recycle bin is the one for the site collection. Are there retention policies assigned to the library? SharePoint is nice enough to tell you:
In this case, we see one. And it has a custom expiration policy, too. A special formula created based on rules using Visual Studio. That will be for a later blog sometime. For now, just know it can be done.
You do not need a custom expiration policy. Let’s say, we add a required column, called Review Date, to a content type based on a document. You cannot apply a retention policy to base content type. Call it “Business Document” for lack of originality. Create a “site column”
and call it “Review Date”. Select Date and Time for the type of information, add it to an existing group on a custom one, state whether it is required to have information (good idea if you are basing your retention policy on it, by the way) and make it date only. You will not need time for this entry. No default value and select whether you want to update all list columns based on this site column. Up to you but that enforces compliance in the site. Hit OK to complete. Now you have the Review date and you can assign this to your Business Document content type.
What does that get you? Any other content type you base (inherit?) from this content type receives the required Review Date. Now you have an easy item to specify as a trigger for the retention policy, an expiration date if you will.
The reason this came about deals with a client’s recent migration. All of the documents after the migration had the same modified date. To have all of them come due at one time was not an option. Add a review date then apply a specific staggered date. Problem solved.
Since the reviews for the documents are yearly, just add 1 to the box.
There are other choices as well: months and days. You decide how long between review dates.
The client did not want to send then to the recycle bin. They just wanted the author to know that the yearly review is due. This is where Action comes in and SharePoint Designer or Visual Studio (depending upon the complexity) is used to design a workflow and attach it to a content type. You can do this in 2010. Why? The choices of action are:
Many choices but the one I needed was the Start a workflow. I now had a timed workflow available.
One thing to understand is that two timed jobs must run for this to work. They are, and in this order:
- Information management policy
- Expiration policy
The first applies the rules. The second executes them. Go to Central Administration, go to Monitoring, and click the link to Review job definitions:
Look for the two jobs. Let’s look at the information policy management first since it must run first for the other to work.
By default, it is set to run weekly.
Normally, this is sufficient. If not, it can be made to run in minutes. Great for testing, by the way. Not great for production. At the end of the screen is an option to run it now.
The next is the expiration policy.
Pretty much the same thing. However, I changed it from weekly to daily.
Now, there is one other trick. Recall, this is a “retention” policy. The default setup is to run once and never run again. That would not do for my client. These documents needed yearly reviews on the same document.
The good people at Microsoft thought of that as well. Included in setting up the retention policy is the ability to set it recurring:
This policy of sending out a message to the author that a yearly review is due for their document is now working. The entire screen appears below:
I am not going into the steps of creating a workflow. Maybe I will on a later blog. I added one thing to the workflow and that was nag mail. It works very well, constantly reminding the user of a task pending and not complete. I did not think this up. You can find it here.