How to retrieve state information about workflows executed by Workflow Manager

If you need to retrieve internal state for workflows executed by Workflow Manager, regardless if they were launched from SharePoint or any other .NET application,  to figure out for example:

  • Why a workflow was suspended or terminated:
  • How long did it take
  • The value of a specific MappedVariables,
  • Etc.

You can do at least in 3 different ways, it is a matter of preferences.


1. Programmatically by using the .NET API Microsoft.Workflow.Client

static string baseAddress = https://<WFM URI>:12290/;

static string workflowName = "<MyWorkflowName>";

staticvoid Main(string[] args)


           WorkflowManagementClient client = WorkflowUtils.CreateForSample(baseAddress, "<MyScope>");

           var SuspendedWorkflows = client.Instances.Get(0, 100, workflowName, Microsoft.Activities.WorkflowInstanceStatus.Suspended);

           Console.WriteLine("Suspended Workflows: {0} \n\n", SuspendedWorkflows.Count);

           foreach (var workflow in SuspendedWorkflows{

              Console.WriteLine("\tInstance Id: {0}", workflow.InstanceName);

              Console.WriteLine("\tCreation Date: {0}", workflow.CreationTime);

              Console.WriteLine("\tLast Modified Date: {0}", workflow.LastModified);

               Console.WriteLine("\tWorkflow Status Details: {0}\n", workflow.WorkflowStatusDetails);


          Console.Write("Press any key to continue ...");



          Note: You need to add a reference to following assemblies: Microsoft.Activities.dll, Microsoft.Workflow.Client.dll and Microsoft.Workflow.Samples.Common.dll



2. Using REST call directly from a Web Browser

Since Workflow Manager WebSite is REST based, you can call it directly from an Internet explorer like below:

https://<WFM URI>:12290/<ScopeName>/$workflows/<WorflowName> /$instances/?$skip=0&$top=100&$workflowStatus=Suspended


     3. Query directly against WFM Database

/*Query to get all Suspeded Workflows*/

SELECT InstanceId, ExecutionTime, LastModified, WorkflowName, WorkflowStatus, WorkflowStatusDetails

FROM [WFInstanceManagementDB].[dbo].[Instances] with(nolock)

where WorkflowStatus ='suspended'

/*Query to get MappedVariables for a specific Suspeded Workflows*/

SELECT t1.InstanceId,t2.Name,t2.Value, t1.ExecutionTime, t1.LastModified, t1.WorkflowName, t1.WorkflowStatus, t1.WorkflowStatusDetails

FROM [WFInstanceManagementDB].[dbo].[Instances] t1 with(nolock)innerjoin [WFInstanceManagementDB].[dbo].[MappedVariables] t2 with(nolock)on t1.InstanceId = t2.InstanceId 

where t1.InstanceId ='<InstanceID>'




Hope it helps!!