Have you ever tried to filter a SharePoint list or document library view using a workflow status column? It’s harder than you’d think…
Workflow status columns report the current status of a workflow. A unique workflow status column is created in your list (or document library) automatically when you create a new out-of-the-box or SharePoint Designer custom workflow. Conveniently, SharePoint uses the name of your workflow as the name of your workflow status column. An example workflow status column is shown below (in yellow). This Email-notification column reports on the status of the Email-notification workflow.
Being a savvy SharePoint user, you’d think you could use the workflow status verbiage as a filter for your list or document library view. Unfortunately, you’d be wrong. You cannot filter your list or library records using the displayed verbiage in your workflow status column(s).
Let’s take a look at an example:
I have a Team assignments list (shown below). It’s a very simple list that allows people to sign up for product areas they want to support. When a new item is created, a custom SharePoint Designer workflow runs and sends some automated notification emails. I can keep tabs on my workflows using the Email-notification workflow status column. As you can see, I currently have items in several different workflow statuses–2 of my list items are in Completed status while another 2 are in In Progress status.
Now let’s say I wanted to create a new list view that only shows me list items that are in Completed status. I go to the List tab, click on Create View and set up my view filter to display only the items where Email-notification is equal to Completed. Sounds perfect, right?
Unfortunately, this view shows zero results–despite the fact that I know I have items whose workflow is in Completed status. Why does this happen? Because Microsoft actually uses numerical status codes to demarcate workflow states. While SharePoint displays “friendly” descriptors for their workflow states (e.g. In Progress or Completed), you need the numerical status codes to be able to filter against the workflow state. The difficult part is finding the correct numeral for the workflow state you want to filter against.
After doing some searching online, I found that the numeral 5 denotes a Completed workflow. When I update my view to filter and display only the items where Email-notification is equal to 5, my list returns the Completed workflow items I was looking for. Here’s a picture of my working filter:
The trick, of course, is figuring out what numerals are used for the other possible workflow states. Here’s a quick list of the workflow states I typically filter against:
- In Progress = 2
- Approved = 16
- Error Occurred = 3
- Not Started = 0
For a more exhaustive list of workflow status codes, visit http://adayinsharepointv3.blogspot.com/2012/08/filter-list-view-by-sharepoint-workflow.html