Event Handlers and Workflow – be careful!

Event Handlers and Workflow – be careful!

If you are using any custom event handlers on your MOSS document/form libraries then be careful that these will not interfere with any running workflows.

This caught me out, I have an event handler attached to the ‘Item Updating’ event of my form library. When an unauthorised user (not in an Admin group) attempts to update an item it will show them an error message.

I had neglected to realise that MOSS workflows run under the system account – ‘SHAREPOINT\system’ and this user account was of course not in the admin group. The result was an error in the running workflow as it could not update the list item. I first tried to add the system account to the group but you cannot do this, I am assuming that’s because the system account cannot be locked down in any way.

The best way to get by this is to add a check in your event handler code to see if the user conducting the event is indeed the system account or not.

Here is the code I have used to check this:

[code lang="csharp"]
CurrUser = properties.UserLoginName.ToString();

If (CurrUser == “SHAREPOINT\system”)
//Do Nothing – User is System Account
//Your code here

Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">