Sitecore Workbox扩展“输入注释”弹出窗口

时间:2013-08-02 06:09:57

标签: sitecore

在Sitecore工作箱命令中,我们可以设置“禁止注释”复选框未选中,当执行该特定工作箱操作时,它会在弹出窗口中请求注释。在那里我想让用户知道通过显示一些自定义文本来键入注释是必需的。这可能吗?

1 个答案:

答案 0 :(得分:2)

这是一篇关于在拒绝某个项目时强制发表评论的博客文章。您也可以轻松地将它用于您的目的:

Sitecore workflows – Comment if you reject something!

如果您需要在用户尝试执行工作流程命令之前显示消息,您可以覆盖Sitecore Workbox.xml控件,并在其代码后面覆盖Comment方法并将"Enter a comment:"更改为任何内容你要。原始方法代码是:

public void Comment(ClientPipelineArgs args)
{
  Assert.ArgumentNotNull((object) args, "args");
  if (!args.IsPostBack)
  {
    Context.ClientPage.ClientResponse.Input("Enter a comment:", string.Empty);
    args.WaitForPostBack();
  }
  else if (args.Result.Length > 2000)
  {
    Context.ClientPage.ClientResponse.ShowError(new Exception(string.Format("The comment is too long.\n\nYou have entered {0} characters.\nA comment cannot contain more than 2000 characters.", (object) args.Result.Length)));
    Context.ClientPage.ClientResponse.Input("Enter a comment:", string.Empty);
    args.WaitForPostBack();
  }
  else
  {
    if (args.Result == null || !(args.Result != "null") || !(args.Result != "undefined"))
      return;
    IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
    if (workflowProvider == null)
      return;
    IWorkflow workflow = workflowProvider.GetWorkflow(Context.ClientPage.ServerProperties["workflowid"] as string);
    if (workflow == null)
      return;
    Item obj = Context.ContentDatabase.Items[(Context.ClientPage.ServerProperties["id"] ?? (object) string.Empty).ToString(), Language.Parse(Context.ClientPage.ServerProperties["language"] as string), Sitecore.Data.Version.Parse(Context.ClientPage.ServerProperties["version"] as string)];
    if (obj == null)
      return;
    try
    {
      workflow.Execute(Context.ClientPage.ServerProperties["command"] as string, obj, args.Result, true, new object[0]);
    }
    catch (WorkflowStateMissingException ex)
    {
      SheerResponse.Alert("One or more items could not be processed because their workflow state does not specify the next step.", new string[0]);
    }
    UrlString urlString = new UrlString(WebUtil.GetRawUrl());
    urlString["reload"] = "1";
    Context.ClientPage.ClientResponse.SetLocation(urlString.ToString());
  }
}