Is there a way to subscribe workflows from integrated apps/add-ins using C# CSOM?

Currently I have:

  1. Created an integrated app/add-in in visual studio
  2. Added the app package to the app catalog in SharePoint Online
  3. Added the app/add-in to a site
  4. Subscribed a workflow from the app/add-in to a document library in the site

So far I have not been able to find a csom call that lists any information about integrated workflows.

The code below finds normal workflows but misses integrated ones:

 var workflowDeploymentService = workflowServicesManager.GetWorkflowDeploymentService();

        var publishedWorkflowDefinitions = workflowDeploymentService.EnumerateDefinitions(false);

        foreach (var pwd in publishedWorkflowDefinitions)
            Console.WriteLine(pwd.DisplayName + " " + pwd.Id);

Once i have the guid i intend to use the code below to associate the workflow. I have used this code to subscribe workflows in another project.

var workflowSubscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();

        WorkflowSubscription newSubscription = new WorkflowSubscription(context)
            DefinitionId = workflow_id,
            Enabled = true,
            Name = "Add To Report Tracker V"

        var startupOptions = new List<string>();

        // automatic start

        // manual start

        newSubscription.EventTypes = startupOptions;

        newSubscription.SetProperty("HistoryListId", "workflowHistoryListId");
        newSubscription.SetProperty("TaskListId", "workflowTaskListId");

        workflowSubscriptionService.PublishSubscriptionForList(newSubscription, list_id);

Here is a link that I have been working from for csom and workflow services.

The site I have added the app/add-in to has over 1000 document libraries in it, and so I want to write a c# program that loops over each document library subscribing the integrated app/add-in workflow using CSOM.

1 Answer 1


The context was the problem. To subscribe integrated app workflows you need to be in the app web context rather than the site context. So you should use:

https://{sharepoint base url}/{site app is added to}/{app name}/

When instantiating the client context.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.