Hi,
Here is the workaround for your reference.
Web web = context.Web;
var list=web.Lists.GetByTitle("MyList");
context.Load(list);
context.ExecuteQuery();
var workflowServicesManager = new WorkflowServicesManager(context, context.Web);
var workflowSubscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();
// get all workflow associations
var workflowAssociations = workflowSubscriptionService.EnumerateSubscriptionsByList(list.Id);
context.Load(workflowAssociations);
context.ExecuteQuery();
var wf = workflowAssociations[0];
List<string> eventTypes = new List<string>() { "WorkflowStart" };
wf.EventTypes = eventTypes;
workflowSubscriptionService.PublishSubscriptionForList(wf, list.Id);
var listitem = list.GetItemById(3);
listitem["Title"] = DateTime.Now.ToString();
listitem.SystemUpdate();
context.ExecuteQuery();
eventTypes = new List<string>() { "WorkflowStart", "ItemUpdated" };//ItemUpdated
wf.EventTypes = eventTypes;
workflowSubscriptionService.PublishSubscriptionForList(wf, list.Id);
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