Today we are going to create a workflow that allows multiple users to approve an item.
What we won’t cover in this post is how to setup security on fields and workflow commands. For that, I recommend John’s post on Security Access Rights.
Based on the business requirements, there are a few things I need to do:
Checks to make sure that at least one user is required for the approval
Make it easy for editors to determine who needs to approve the content
Workflow
I’ve gone ahead and built out my workflow with the needed commands and actions and selected some amazing icons.
MultiApprove Workflow
User List Field Type
First, we need to build a custom Field Type that allows us to select the users we want to require. I’ve called mine User List. John blogged about a users droplist to accomplish this, so we’re going to build it as a multilist using another blog showing how to create a custom multilist field. I’ve created a txt of Lookup.cs as it’s a bit long.
Now, actually setup the Field Type in Sitecore. In the core database, I’ve created mine here: /sitecore/system/Field types/List Types/User List using the template Template Field Type
Set the Assembly and Class appropriately. Mine were:
Assembly: sandbox.BusinessLogic Class: sandbox.BusinessLogic.Common.UserLookup
Workflow Template
With the new user list created, we can create our template like so. I’ve also removed editing permissions to Everyone on the Approved By and the Awaiting ApprovalFrom fields as we don’t want editors to be able to change these.
MultiApprove Template
Once you’ve created this, make sure you inherit it to either your site’s Standard Template or Page Template. In my case, my News Page inherits it.
MultiApprove Template Inheritance
Users Assigned Check Action
In my case, we want to prevent items from progressing in the workflow if they have not selected any users to approve it. So, we want to create an Action under the Draft’s Submit command. I’ve named mine UsersAssignedCheck.
User Assigned Check Action
In the Type String field, fill in the classNamespace.Classname, AssemblyName. For this example, we’ll be using:
sandbox.BusinessLogic.Workflows.MultiApprove.UsersAssignedCheck, sandbox.BusinessLogic
This is the notification you will receive if you’re not the last required approver.
Approval Notification
The item is updated, so all users can easily see what approvals are still required. You can see that I have approved it. Note: I am an admin during this test. Normal content editors would not have the option to edit these fields at this point.
Test News Page
We’re done! Or are we?
This is a working proof of concept. Ideally you won’t have hard-coded strings or display unnecessary users. Maybe we want to hide the commands to those users who have already approved, that’s for another post! Enjoy!
Leave a Reply