2

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.

1

I don't think this is possible in CSOM. It unfortunately calls the updated workflow. System Update in SSOM does not fire the updated workflows however. So if you have the option of switching you could use system updates. If you want to do this in CSOM you could use some hidden fields to track if the item has been updated by a workflow and act accordingly.

  • SSOM is not a option as this is a SharePoint Online environment. The issue is those lists has approval enabled and once a item is updated users will receive an approval email. But those are already approved contents and I don't want users to get a new set of approval emails for same content. – Damitha Aug 3 '17 at 3:17
  • I would suggest then adding a hidden column that will track if the item was updated by the event. If you then check the column in your workflow and then reset it in the workflow you can essentially avoid the workflow actually doing anything. – belmer1416 Aug 3 '17 at 13:05
1

It was answered by Lee__li here https://social.technet.microsoft.com/Forums/en-US/75ff257b-ed2d-4281-91be-88a9cdb334fe/stop-workflow-triggering-when-systemupdate-is-called-sharepoint-online?forum=sharepointdevelopment

My workflow was deployed using a App and I had to load the app web to get subscriptions.

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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