2013-08-02 55 views
1

在Sitecore工作箱命令中,我們可以取消選中「取消評論」複選框,並在執行該特定工作箱操作時,它會要求在彈出窗口中留言。我希望讓用戶知道,通過顯示一些自定義文本來輸入評論是必需的。這可能嗎?Sitecore工作箱擴展「Enter a Comment」popup

回答

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()); 
    } 
} 
+0

感謝您的回覆Maras。我們實際上在做同樣的事情。但客戶希望事先向用戶提供建議,因爲警告信息出現在單獨的彈出窗口中。 –

+0

@KasunJayasinghe我已經更新了我的答案。它現在回答你的問題嗎? –

+0

是Maras,它完全回答了我的問題。真的很感謝這一點。 –