Extract Lists items Workflow data

Hi,

I have a CSOM application that currently extracts List items data.

I need to identify if the lists have workflows associated, and then extract the workflow related data for each item (tasks, history, ...).

I've tried with the following on a Document list that has a "Disposition Workflow" defined, but without success.

var workflowAssociations = workflowSubscriptionService.EnumerateSubscriptionsByList(list.Id);
Any idea ?

Thanks!

September 9th, 2015 4:28pm

Hi,

The following code for your reference:

string siteCollectionUrl = "http://YourSiteURL ";

// connect to the workflow services via a CSOM client context
var clientContext = new ClientContext(siteCollectionUrl);

NetworkCredential spCredential = new NetworkCredential ("UserName", "Pwd");  

clientContext.Credentials = spCredential; 

var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);
Web web = clientContext.Web;

List list = web.Lists.GetByTitle("Documents");
clientContext.Load(list);
clientContext.ExecuteQuery();

// connect to the subscription service
var workflowSubscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();

// get all workflow associations
var workflowAssociations = workflowSubscriptionService.EnumerateSubscriptionsByList(list.Id);
clientContext.Load(workflowAssociations);
clientContext.ExecuteQuery();

foreach (var association in workflowAssociations)
{
	string name = association.Name;
	Console.WriteLine(name);
}

If the issue still exists, I suggest you debug your code and provide some error message for further research.

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 2:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics