Event Handlers and Workflow – be careful!

10 03 2009

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:

CurrUser = properties.UserLoginName.ToString();

If (CurrUser == “SHAREPOINT\\system”)

{

//Do Nothing – User is System Account

}

else

{

//Your code here

}

Good luck!

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: