Filtering a SharePoint list by Workflow Status
By Kit
The most recent problem I ran into was when I tried to filter out items that had a certain Workflow status in the list. More specifically, I was trying to filter on items that had errored out and had a status of “Error Occurred” in the list.
My first thought was to try to filter based on the text. Using a contains didn’t work; I got a message about you can only use a contains on Single line of text, Multiple line of text, or Choice fields.
The solution is to filter based on the integer value:
Listed below are the other values in the enum that you can use for the various states.
public enum SPWorkflowStatus
{
NotStarted = 0,
FailedOnStart = 1,
InProgress = 2,
ErrorOccurred = 3,
StoppedByUser = 4,
Completed = 5,
FailedOnStartRetrying = 6,
ErrorOccurredRetrying = 7,
ViewQueryOverflow = 8,
Max = 15,
}