2013-05-16 46 views
8

我目前使用InvalidPluginExecutionException發送消息給用戶,但事實證明,該消息是英文"Business Process Error"超出該錯誤框出現按鈕"download log file"。這不是錯誤,因爲用戶正在嘗試複製記錄,如代碼中所示。有沒有其他的方式,而不必使用InvalidPluginExecutionException來顯示警報?如何通過插件向用戶發送警報而不使用InvalidPluginExecutionException?

QueryExpression query1 = new QueryExpression(); 
query1.ColumnSet = new ColumnSet(true); 
query1.EntityName = "new_appraisers"; 

EntityCollection ec = service.RetrieveMultiple(query1); 

if (ec.Entities.Count <= 0) 
{ 
    log.Tb_Log_Create("Appraiser created"); 
} 
else 
{ 
    foreach (Entity app in ec.Entities) 
    { 
     if (app["fcg_appraiser"].ToString() == name) 
     { 
      log.Tb_Log_Create("appraiser allready exist"); 

      throw new InvalidPluginExecutionException("The name allready exists"); 
     } 

     if (app["new_login"].ToString() == login) 
     { 
      log.Tb_Log_Create("appraiser allready exist"); 

      throw new InvalidPluginExecutionException("The login allready exists."); 
     } 
    } 
} 

回答

8

從插件向用戶顯示消息框的唯一方法是使用驗證階段的異常。但是,您可以使用javascript,在窗體的On_Save事件上執行簡單的OData查詢,並顯示包含所需信息的警告框,然後取消保存表單。

這將允許您顯示您想要的任何自定義消息,並防止插件觸發並顯示下載文件對話框。

1

但是,我可能會遲到一些,但在更新版本的CRM中,有幾種可能性來實現您想要的功能。在更好的beeing:

  1. 業務規則
  2. 使用JS和通知使用

我希望微軟不閱讀這個,但...

您也可以使用同步插件,並對業務流程錯誤彈出對話感到滿意。我剛剛發現這個Dialog在某種程度上是可以破解的。只需在如下所示的Exeptions消息中返回HTML:

throw new InvalidPluginExecutionException(
@"<img height='16px' src='http://emojione.com/wp-content/uploads/assets/emojis/1f644.svg'> <strong>Oh snap!</strong> 

It seems the record can not be saved in its current state.  

"); 

這會導致某種情況。像這樣:

enter image description here

+1

這一切都不是在2011年CRM提供(也許哈克HTML作品,雖然) – Alex

+0

是的,沒錯。好點子。 – nozzleman

+0

我喜歡html smylie hack –

相關問題