Forum Discussion
Alexander Korablinov
Jul 07, 2017Copper Contributor
How do I get workflow instances for list item on the client side
Hi, Question: What client side API can I use to retrieve all workflow instances for SharePoint list item? Environment: SharePoint 2013/2016 with SharePoint 2010 Workflow platform, i.e. Workflo...
Russell Gove
Jan 17, 2018Iron Contributor
This is working for me
let listId = await this.getListId(this.properties.technicalRequestListName);
var context = SP.ClientContext.get_current();
var workflowServicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, context.get_web());
var workflowInstanceService = workflowServicesManager.getWorkflowInstanceService();
var workflowDeploymentService = workflowServicesManager.getWorkflowDeploymentService();
//Get all the definitions from the Deployment Service, or get a specific definition using the GetDefinition method.
let wfDefinition:SP.WorkflowServices.WorkflowDefinition = (await this.getWorkFlowByName(workflowDeploymentService, workflowName));
let wfDefinitionId: string = (await this.getWorkFlowByName(workflowDeploymentService, workflowName)).get_id();
let wfInstances:SP.WorkflowServices.WorkflowInstanceCollection = workflowInstanceService.enumerateInstancesForListItem(listId, ItemId);
context.load(wfInstances);
context.executeQueryAsync(
(sender, args) => {
var instancesEnum = wfInstances.getEnumerator();
let listId = await this.getListId(this.properties.technicalRequestListName);
var context = SP.ClientContext.get_current();
var workflowServicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, context.get_web());
var workflowInstanceService = workflowServicesManager.getWorkflowInstanceService();
var workflowDeploymentService = workflowServicesManager.getWorkflowDeploymentService();
//Get all the definitions from the Deployment Service, or get a specific definition using the GetDefinition method.
let wfDefinition:SP.WorkflowServices.WorkflowDefinition = (await this.getWorkFlowByName(workflowDeploymentService, workflowName));
let wfDefinitionId: string = (await this.getWorkFlowByName(workflowDeploymentService, workflowName)).get_id();
let wfInstances:SP.WorkflowServices.WorkflowInstanceCollection = workflowInstanceService.enumerateInstancesForListItem(listId, ItemId);
context.load(wfInstances);
context.executeQueryAsync(
(sender, args) => {
var instancesEnum = wfInstances.getEnumerator();
- Russell GoveJan 18, 2018Iron ContributorSorry for the malfomed text. I documented what I was doing here: https://wordpress.com/post/yetanothersharepointblog.wordpress.com/573