Is there a way to subscribe workflows from integrated apps/add-ins using C# CSOM?
Currently I have:
- Created an integrated app/add-in in visual studio
- Added the app package to the app catalog in SharePoint Online
- Added the app/add-in to a site
- 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);
context.Load(publishedWorkflowDefinitions);
context.ExecuteQuery();
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
/*
startupOptions.Add("ItemAdded");
startupOptions.Add("ItemUpdated");
*/
// manual start
startupOptions.Add("WorkflowStart");
newSubscription.EventTypes = startupOptions;
newSubscription.SetProperty("HistoryListId", "workflowHistoryListId");
newSubscription.SetProperty("TaskListId", "workflowTaskListId");
workflowSubscriptionService.PublishSubscriptionForList(newSubscription, list_id);
context.ExecuteQuery();
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.