Hi,
I'm attempting to write a simple test application to list the workflow definitions on a SharePoint Online site. I've tried both a provider hosted CSOM and JSOM approach and I cannot get any definitions listed. The CSOM approach is standard code as follows..
public ActionResult About() { User spUser = null; var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { if (clientContext != null) { WorkflowServicesManager wfServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web); WorkflowDeploymentService wfDeploymentService = wfServicesManager.GetWorkflowDeploymentService(); WorkflowDefinitionCollection wfDefinitions = wfDeploymentService.EnumerateDefinitions(false); clientContext.Load(wfDefinitions); clientContext.ExecuteQuery(); StringBuilder builder = new StringBuilder(); foreach (var def in wfDefinitions) { builder.AppendLine("Workflow" + def.DisplayName); } ViewBag.Message = builder.ToString(); } } return View(); }
I've created and deployed both Sharepoint 2010 approval workflows and 2013 list based workflows and a site workflow and non of the definitions show up.
My JSOM and CSOM apps run fine in every other respect but no workflows are listed. Any idea greatly appreciated..
Thanks
Nigel