none
How can I trigger SharePoint Site workflow from another Site Workflow using REST API ? RRS feed

  • Question

  • In SharePoint Online we have two site workflows.

    In the end stage one site workflow I want to call another site workflow using REST API. Is it possible to do so?



    Monday, January 2, 2017 1:37 PM

All replies

  • Hi,

    You could try to check whether the REST API StartWorkflowOnListItemBySubscriptionId meet your requirement.

    Here are some threads for your reference:

    https://blogs.msdn.microsoft.com/sridhara/2014/08/21/fix-sharepoint-2013-workflow-recursion-prevention-part-2/

    https://social.msdn.microsoft.com/Forums/office/en-US/5508fd39-6f21-4ee0-9489-1a2bd39fadb9/call-sharepoint-2013-site-workflow-from-another-2013-site-workflow?forum=sharepointgeneral

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 3, 2017 2:03 AM
  • Thanks Lee.

    I am aware about these articles.

    This explains how to trigger List workflow using REST API. I want REST API end point to trigger site workflow.

    Tuesday, January 3, 2017 7:34 AM
  • Hi,

    I tried to start site workflow by rest api but no luck currently, here are some workarounds for your reference.

    Create SharePoint 2010 workflow so you could use Start a Site Workflow action.

    Starts the site workflow by CSOM, here is my test code for your reference:

    WorkflowServicesManager workflowDeploymentService = new WorkflowServicesManager(context, context.Web);
                    var publishedWorkflowDefinitions = workflowDeploymentService.GetWorkflowSubscriptionService().EnumerateSubscriptions();
                    context.Load(publishedWorkflowDefinitions);
                    context.ExecuteQuery();
    
                    // find the first workflow definition
                    var firstWorkflowDefinition = publishedWorkflowDefinitions.Single(def=>def.Name=="WF2") as WorkflowSubscription;//.First();
    
                    // connect to the subscription service
                    var workflowSubscriptionService = workflowDeploymentService.GetWorkflowSubscriptionService();
                  
                    // connect to the instance service
                    var workflowInstanceService = workflowDeploymentService.GetWorkflowInstanceService();
    
                    // start the workflow
                    var startParameters = new Dictionary<string, object>();
                    workflowInstanceService.StartWorkflow(firstWorkflowDefinition, startParameters);
                    context.ExecuteQuery();

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 3, 2017 10:06 AM