Get Workflow Status Programmatically in SharePoint Using Client Side Object Model C#

This post explains how to get SharePoint list item’s workflow status using Client Side Object Model programming, using the below code we can find workflow status id. Because workflow status field internally save the workflow status id only not as name,

List oList = clientContext.Web.Lists.GetByTitle("Documents");
ListItem item = oList.GetItemById(14);
Field workflowStatusField = item.ParentList.Fields.GetByTitle("WorkflowName");
var workflowStatusValue = item[workflowStatusField.InternalName];

In that code workflowStatusValue receive a status id as a list item workflow status. Here I’ve listed workflow status code and their status,

NotStarted = 0
FailedOnStart = 1
InProgress = 2
ErrorOccurred = 3
StoppedByUser = 4
Completed = 5
FailedOnStartRetrying = 6
ErrorOccurredRetrying = 7
ViewQueryOverflow = 8
Canceled = 15
Approved = 16
Rejected = 17

for testing I have created a workflow, named as “WorkflowName” and assigned to one document.


In the below screenshot we can see that the code returns 2, which means workflow status is in-progress.


Feel free to contact me if you have any doubts and queries through comments.