Custom SharePoint Approval Workflow

Posted on: December 3, 2017

If you’ve ever used the OOTB publishing approval workflow, you will know that it’s pretty good and easy. But, if you’ve ever had some slightly niche requirements, then you may have had an absolute nightmare trying to figure out how to implement it!

If you want to do some customisation, like route the approval task to different groups for different items, then you will need to make a new workflow. So you can copy the OOTB one and add in a lookup of some kind to set the Approver field. Great, that was easy! Sure was easy, and that shouldn’t really affect anything should it? You give it a test and discover that approving your task didn’t affect the actual list item’s approval status. Huh. Oh well that makes sense, because you normally set that when creating the workflow…but that is on the site. There must be a setting in Designer. Oh. There isn’t. Never fear! We can add in some steps to the workflow to set it. Take that Designer, I have bested you! You test again and it works like a charm. But then you think, what if you just approve the item from within the list, rather than the task you have been assigned? You guessed it, it doesn’t stop the workflow. WHAT?! Argh!

Eventually, you land at the solution. I will have my custom workflow, but I will control it through event receivers. I will start it and end it, I will set the approval status, it will all happen through event receivers. That is kind of annoying to set up, let’s not kid ourselves, but unless someone else can shed some amazing insight onto this, that is the way to do it.

There is one other thing to note about custom workflows. They are necessary when you want to refer to a custom field in a list. So if you thought you could be clever and use the OOTB workflow and have a field on the item that is the Approver group to route to, then you are sadly mistaken. I haven’t tried it, but apparently you can limit a workflow to a content type and so could put the field you want in a content type and then have your list inherit that. In theory that should allow the OOTB workflow.