El Blanco's Office 2007 Blog

Monday, July 20, 2009

Interrogate the Document Version within the ItemCheckingIn Event Receiver?

I've added an event receiver to a content type, and I've overridden the ItemCheckingIn event. My scenario is that if the document is being checked in as a Major version (i.e. x dot zero) then unless it fulfils some other criteria I want to prevent the check in from occurring (i.e. set the properties.Cancel property to true, and set the properties.ErrorMessage property to some message indicate that the user must perform some action or other before a major version can be checked in).

So my scenario is that in the ItemCheckingIn event receiver method I want to interrogate whether the document is being checked in as a minor or a major version - sounds simple enough, right?

I first of all checked the following property within my event receiver:


But I soon realised that since ItemCheckingIn is the synchronous event receiver method, then the item hasn't actually been checked in yet, so I won't have the new version number applied yet. So I changed this to check the following within my event receiver:


However this still doesn't work – when I check in a major version, it just gives me the minor version number. If I check this property afterwards in the ItemCheckedIn event then I DO get the correct major version number, but obviously this is too late to cancel the check in operation since ItemCheckedIn is the asynchronous event receiver and it's not possible to prevent the operation in this event receiver method.

Has anyone come across this problem before – in the ItemCheckingIn event receiver method how can I tell what version of the document is being checked in i.e. whether it's a major or a minor version?!


  • Did you ever get a solution to this issue. I'm working with the same challenge, check out http://mqsharepoint.blogspot.com.

    By Blogger Morten Marquard, at 12:01 pm  

  • Hi Morten,

    See my update post here:


    Which describes the solution to the issue.

    Kind Regards,


    By Blogger Chris White, at 5:30 pm  

Post a Comment

<< Home