我正在尝试在案例(“事件”)上注册一个插件,创建同步后事件以成功调用 CloseIncidentRequest。我让 CloseIncidentRequest 在案例更新发布事件上成功运行,但在创建时我不断收到“需要在提交之前启动事务”异常。
有谁知道这是否是一个已知问题,或者是否有人在案例创建发布事件中运行此问题?我已经看到有关从同步更改为异步的帖子-如果我将插件更改为运行异步,那确实有效-但理想情况下,我希望它同步运行,以便用户可以在按下保存时看到案例已解决.
private const int IncidentResolutionStatus_Closed = 2;
private const int IncidentStatusCode_ProblemSolved = 5;
Entity resolution = new Entity("incidentresolution");
resolution["subject"] = "Case Resolved";
resolution["incidentid"] = new EntityReference("incident", IncidentId);
resolution["timespent"] = timespent;
resolution["statuscode"] = new OptionSetValue(IncidentResolutionStatus_Closed);
CloseIncidentRequest closeincidentRequest = new CloseIncidentRequest()
{
IncidentResolution = resolution,
Status = new OptionSetValue((int)IncidentStatusCode_ProblemSolved)
};
service.Execute(closeincidentRequest);