Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)

share|improve this question
1  
Could you provide the exact code that you tried? What, specifically, happened when you tried this for each of the four event receiver events? Were the events not firing? Was it being left as a major check in? Were you getting errors/exceptions? –  Servy May 31 '12 at 15:20
    
I don't get any errors or exceptions, the document simply checks in as a major version, ignoring my changes. However the event is properly attached because if I use properties.Cancel = true; the event is canceled properly. –  João Gala Louros May 31 '12 at 15:58
add comment

1 Answer

My first instinct after hearing the problem is to go to the ItemCheckedIn method, and if it was a major check in, check it out and check it in again as a minor check in. Alternatively, attach to the ItemCheckingIn event, and if it's a major check in cancel the event and (with event firing disabled) check the item in as a minor check in.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.