Determine Check In Major / Minor Version in Item Updating / Updated Event Receiver

Recently, I need to determine whether user check in major version to the file in document library. I found a good article from Morten Marquad& to do it. The way to determine is to read before and after properties of SharePoint field “vti_level“. I just want to re-iterate it here, so I don’t miss it.

The value of “vti_level” after and before properties would be as per table below and these matrix ONLY WORK IN ItemUpdating and ItemUpdated event receiver. When I tried it in ItemCheckedIn event receiver, it gives you different values.

Event iBefore iAfter
Check in major version 255 2
Check in minor version 255 255
public override void ItemUpdating(SPItemEventProperties properties)
 int iBefore = (int.TryParse(properties.BeforeProperties["vti_level"].ToString(), out iBefore) ? iBefore : -1);
 int iAfter = (int.TryParse(properties.AfterProperties["vti_level"].ToString(), out iAfter) ? iAfter : -1);

 // If check in major version
 if (iAfter != iBefore)
  // do your code here ...



Tagged: , , , , , , , , , , ,

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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: