我有一个插件,它触发事件实体的更新。它在另一个表(new_documentaccess)中创建一个新记录。这个new_documentaccess记录需要具有与事件实体相同的所有者。由于安全角色导致的CRM 2013异常处理
现在,我明白我不能像实体上的任何其他字段一样通过执行简单赋值来设置Owner字段。
所以,我在下面写道。
public void CreateDocumentAccess(Incident incident)
{
new_documentsaccess documentAccess = new new_documentsaccess();
documentAccess.new_CaseId = incident.ToEntityReference();
documentAccess.new_name = incident.OwnerId.Name;
Guid recordId = crmService.Create(documentAccess);
var request = new AssignRequest{
Assignee = new EntityReference(SystemUser.EntityLogicalName, incident.OwnerId.Id),
Target = new EntityReference(new_documentsaccess.EntityLogicalName, recordId)};
crmService.Execute(request);
}
但是,我得到了执行过程中出现以下错误,当我与
歇调试时抛出的异常时:启用公共语言运行时异常。
抛出在行
var request = new AssignRequest{
Assignee = new EntityReference(SystemUser.EntityLogicalName, incident.OwnerId.Id),
Target = new EntityReference(new_documentsaccess.EntityLogicalName, recordId)};
主体用户(ID = e9e3a98d-a93e-e411-80bc-000c2908bc67,类型= 8)是 丢失prvAssignnew_documentsaccess特权 (ID = 7ecaf3da-77c8 -4ee3-9b29-e5a4455cd952)“}
我的插件代码如下
try
{
CreateDocumentAccess(Incident incident);
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred while creating the document access.", ex);
}
catch (Exception ex)
{
TracingService.Trace("ExecutePreIncidentUpdate: {0}", ex.ToString());
throw;
}
如果我只是使用前端运行它作为用户,我得到以下错误。
退出PluginPreIncidentUpdate.Execute(),相关性id:4e7e4c3c-3cef-46ab-8d08-a6d0dbca34c7,发起用户:be179876-9b39-e411-80bb-000c2908bc67
问题
我应该进行哪些代码更改,以便即使在出现上述错误时出错 ,ErrorDetails.txt也会捕获 错误
Principal user (Id=e9e3a98d-a93e-e411-80bc-000c2908bc67, type=8) is missing prvAssignnew_documentsaccess privilege (Id=7ecaf3da-77c8-4ee3-9b29-e5a4455cd952)
?为什么它不会发生?
你能发布更多正在下载的ErrorDetails.txt文件吗?文件顶部的XML是什么? – Nicknow 2014-09-24 02:01:26