none
Stop Workflow Triggering When SystemUpdate is called- SharePoint Online RRS feed

  • Question

  • I am using SystemUpdate in CSOM to update list items. It works fine and does not update modified date and modified by field. But it will trigger workflow attached to the list. Is there a way to stop SystemUpdate from triggering workflow?

    If there is not a way to do it, what is my best alternative? There are many sites and lists and I would like to avoid going to each list and disable/removing workflows.
    • Edited by DamithaW Tuesday, August 1, 2017 10:28 AM
    Tuesday, August 1, 2017 10:28 AM

Answers

  • 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

    • Marked as answer by DamithaW Friday, August 4, 2017 9:20 AM
    Wednesday, August 2, 2017 3:48 AM