I am playing around with SPItemEventProperties and it looks like it's little bit messed up (or I am totally missing the point).
Here is what I am trying to do. When a user do a "Major check in" I simply change it to a "Minor check in". No pop-ups, no magic, I am just trying to do this as simple as possible by changing the SPItemEventProperties.AfterProperties["vti_level"] to "255" when it's set to "1" (this link explains check in values). However I didn't find any successful solution so far. I already tried in ItemUpdating, ItemUpdated, ItemCheckingIn, ItemCheckedIn and nothing...
The user flow is the following:
- User right click (or SharePoint dropdown) on a document and select "Check Out"
- Popup shows up saying "you are about to check out, blah blah blah, Use local Drafts?" The user will check "Use local drafts folder" and press "Ok"
- Document was checked out, now the user will try to check in as Major version
- The user successfully checks in the document, but as a "Minor version" instead of "Major version"
The simplified code looks like:
public override void ItemUpdating(SPItemEventProperties properties) {
foreach (DictionaryEntry de in properties.AfterProperties)
{
string key = de.Key.ToString();
string value = de.Value.ToString();
//If the document is about to be published (made a major version) ...
if (key.Equals("vti_level") && value.Equals("1"))
{
//set as minor version
properties.AfterProperties["vti_level"] = "255";
}
}
}
(This my sound a bit stupid, but I added a library property to "Prevent Major check ins" and that's why I am trying to do this)