如何在不使用InvalidPluginExecutionException的情况下通过插件向用户发送警报?

Hug*_*lva 9 c# plugins crm dynamics-crm-2011

我目前正在使用InvalidPluginExecutionException该消息发送给用户,但事实证明该消息是英文的,"Business Process Error"超出该消息的错误框出现在按钮上"download log file".这不是错误,因为用户正在尝试复制记录,如代码中所示.还有其他方法,而不必使用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.");
        }
    } 
}
Run Code Online (Sandbox Code Playgroud)

Dar*_*ryl 8

从插件向用户显示消息框的唯一方法是使用验证阶段的异常.您可以使用javascript,在表单的On_Save事件上执行简单的OData查询,并显示包含您喜欢的任何信息的警告框,并取消保存表单.

这将允许您显示您想要的任何自定义消息,并保持插件不会触发并显示下载文件对话框.