SharePoint 2010文档库版本注释
问题描述:
我想在签入文档之前强制用户添加他们的评论。 当用户选择签入时,默认弹出页面将显示为了选择版本和写评论,但评论字段不是强制性的,我们可以将它作为必填字段吗?SharePoint 2010文档库版本注释
答
你可以通过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;
}
}
}