Nintex Newbie

How do I get workflow instances for list item on the client side


Question: What client side API can I use to retrieve all workflow instances for SharePoint list item?

SharePoint 2013/2016 with SharePoint 2010 Workflow platform, i.e. Workflow Manager is NOT installed.
Nintex Workflow

I have the following:
1.    SharePoint site URL
2.    List name
3.    Workflow name
4.    Item ID

I have already tried the following approaches:
1.    WorkflowLog[] NintexWorkflowService.GetWorkflowHistoryForListItem(int itemId, string listName, SPWorkflowState stateFilter, string workflowNameFilter)
This method is not reliable because it may return null even if workflow instance exists.
2.   CSOM WorkflowInstanceService.EnumerateInstancesForListItem(Guid, Int32)
The following C# example does not work:
ClientContext clientContext = new ClientContext(siteUrl);
var workflowServicesManager = new SP.WorkflowServices.WorkflowServicesManager(clientContext, clientContext.Web);
var workflowInstanceService = workflowServicesManager.GetWorkflowInstanceService();
var workflowInstances = workflowInstanceService.EnumerateInstancesForListItem(new Guid("{f79ba745-ffe8-4e77-b3a4-3f37ab7f1b0d}"), 100);

ExecuteQuery throws an exception: Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. "GetWorkflowInstanceService
new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager()"

I will appreciate any help.

2 Replies
Workflow Veteran

Re: How do I get workflow instances for list item on the client side

Couldn't you make a SharePoint Query of the list filtering by the status of the workflow?

0 Kudos
Nintex Newbie

Re: How do I get workflow instances for list item on the client side

Hi Fernando, thank you for the reply.

If you mean querying the workflow status column value, how could this help me with getting all workflow instances?

0 Kudos