The trouble with filtering on workflow status columns…


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.

wf-filtering-01

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.

wf-filtering-01

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?wf-filtering-02

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:

wf-filtering-03

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

Advertisements

15 comments

  1. Another easy way to find out what number to use – put the view that contains the workflow column into datasheet view. That view displays the number corresponding to the status..

  2. Great, just what I was looking for. Still why don’t they allowed for the full text instead of only integers. Would be much more intuitive.

  3. Excellent, researched the issue, found your experience within seconds and now don’t need to bother the SP Admin, sweet!

  4. Hi Sarah, I have a list and a workflow. Now, I want to create a new view to see only the “Completed” fields. In this moment, I have a problem in the select list on the filter, no appear your Email-notification field, in my case workflowTest. Thanks

  5. Good afternoon Sarah,

    I created a list and a relationated workflow like you. Now, I have a new view of this list, and I want to filter this list for WorkflowStatus, specially by Approved Status. I look that in the select filter appear you “Email-notification”, the name of the workflow, I think. In my case, this field “WorkflowTest” doesn’t appear in my select list. Can you help me? Thanks

    1. Have you tried modifying the view to add the workflow field to your display? The workflow field should be available as a field to add. If it isn’t, then you have an issue with the publishing of your workflow.

  6. Hi Sarah, The numbers are great but what if the field is not available for filtering? It is not in the dropdown when I go to make a view. I am using a SPD 2013 WF. Seems the workflow status is a hyperlink. Thank you.

    1. Thanks for your reply.
      you are right. so I am trying to create views. when I create a view and follow your article in the filter section I am not able to find column i.e generated by the workflow but in a sort section I can see my column.

      so Please tell me how I am able to get my column in filter section.

      Thanks ,

  7. i am trying create a new view. I am not able to see my workflow field in filter dropdown but it is visible in sort dropdown. Please tell me what am i missing?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s