0

I've got an event receiver handling ItemUpdating; now, I'd like to know if the update was triggered from a SharePoint 2013 workflow (setting the workflow status for example) or directly by a user (edit form, REST API whatever).

Access rights in the workflow context are different, trying to access another list fails with access denied for example, so I need to know if I'm running in a workflow context to determine if access denied error is OK(inside workflow) or is an Error(normal update).

properties.Web.CurrentUser is however the same in both cases;

0

There might be different ways to do this. But normally I validate this information by

  1. Adding a hidden field to the list - WorkflowUpdated - Yes/No field
  2. Whenever Worflow updates the list item it put a Yes to this hidden field
  3. In the EventReceiver, now you can check the value of this field to find whether it was updated by the Workflow or not.
  • I'm aware of this approach, but I'm not sure it'll cover all eventualities: on starting the workflow the update that sets the hidden field will trigger the ItemUpdating event receiver without the hidden value. Also, if a normal update occurs while the workflow is still running, the event receiver will falsely assume it'S running in a workflow context. – mabene Jan 27 '15 at 13:58

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.