0

I have the following ItemUpdated event Receiver and everything in the code works.

public override void ItemUpdated(SPItemEventProperties properties)
{
    base.ItemUpdated(properties);

    SPList list = properties.List;

    var approvalStatus = properties.ListItem["doc_approvalStatus"] as string;
    if (approvalStatus == "Final-Approved")
    {
        if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
        {
        }
        else
        {
            //This is triggered by events other than check-in action.
            SPFile file = properties.ListItem.File;
            SPListItem item = file.Item;
            properties.ListItem["doc_version"] = file.MajorVersion;
            properties.ListItem.Update();
            item.File.CheckIn("");
            //item.File.Publish("");
        }
    }
}

Except the part that when I use item.File.CheckIn() i wish to not update the version number.

If my version number is 42, and I run the event receiver it set the version to 43, I guess because of the item.File.CheckIn(). Is there a way to avoid updating the version number in my event receiver?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.