No workflow definitions returned

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

April 22nd, 2015 9:47am

This is a good post :

http://ranaictiu-technicalblog.blogspot.com/2013/05/sharepoint-2013-workflow.html

Free Windows Admin Tool Kit Click here and download it now
April 25th, 2015 5:28am

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

Other recent topics Other recent topics