0

I am trying to monitor the status of workflows using JavaScript in the SharePoint Farm.

List A: Number of Completed: In Progress: Error occurred:

List B: ...

1 Answer 1

0

Get Workflow status via CSOM

function getWorkflowStatus(listTitle,listItemId,workflowTitle, success,error)
{
  var context = new SP.ClientContext.get_current();
  var web = context.get_web();
  var list = web.get_lists().getByTitle(listTitle);
  var listItem = list.getItemById(listItemId);   
  context.load(listItem);
  context.executeQueryAsync(
     function() {
       var workflowStatusField = listItem.get_parentList().get_fields().getByTitle(workflowTitle); //get workflow status field
       var workflowStatusValue = listItem.get_item(workflowTitle); //get workflow status field value
       success(workflowStatusValue); 
     },
     error
  );
}



//Example: check whether workflow has been completed for a List Item
var listTitle = 'Pages';
var listItemId = 1;
var workflowTitle = 'Approval';
getWorkflowStatus(listTitle,listItemId,workflowTitle,function(status){
   if(status == 5){  
       console.log('Approval is completed');
   } 
},
function(sender,args){
   console.log(args.get_message());
});

https://ravichandran.blog/2016/02/12/get-workflow-status-programmatically-in-sharepoint-using-client-side-object-model-c/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.