ehabzag
ehabzag

Reputation: 99

SharePoint 2010 Document library versions comment

I would like to force users to add their comments before checking-in document. When a user selects Check-in, the default popup page will show in order to select version and write comments, but comments field is not mandatory, can we make it as a required field??

Upvotes: 2

Views: 5809

Answers (1)

StaWho
StaWho

Reputation: 2488

You could do it via EventReceiver:

public class EventReceiver1 : SPItemEventReceiver
{
    public override void ItemCheckingIn(SPItemEventProperties properties)
    {
        base.ItemCheckingIn(properties);
        string comment = (string)properties.AfterProperties["vti_sourcecontrolcheckincomment"];
        if (string.IsNullOrEmpty(comment))
        {
            properties.ErrorMessage = "Comment empty";
            properties.Cancel = true;
        }
    }
}

Upvotes: 5

Related Questions