c# - 在 MS CRM 2015 错误消息中更新实体时
问题描述
我在 crm 2015 中有一个事件表。在 spme 操作之后,事件实体变得被动。在我的数据库中,被动事件是通过查看状态和状态列来理解的。如果事件是被动的,则状态码变为 1,状态码变为 5。
事后变得被动。我想对那个事件实体做些事情。
作为操作员,我想更改状态和状态以激活事件。(状态=0,状态=1)
如果我成功了,我想将 new_anketgonderildi 字段(位字段)更新为 true。然后再次使事件被动并更新实体。
但是更新实体时出现错误。
这个案子已经解决了。关闭并重新打开案例记录以查看更新。
我意识到如果事件处于活动状态,我可以更改 new_anketgonderildi 字段。当事件处于被动状态时我无法改变。要更改位值字段,我必须激活事件更改位字段,然后再次停用事件。
解决方案
这就是 CRM 的工作方式。有许多实体(包括案例/事件)一旦变为非活动(被动)就无法再编辑。
您将需要;
new_anketgonderildi
在关闭案例之前更新。- 重新激活已关闭的案例,更新
new_anketgonderildi
,然后再次关闭案例。
Sample中有一个后面的例子:Validate record state and set the state of the record。
private void SetState(EntityReference caseReference)
{
// Open the incident
// Create the Request Object
SetStateRequest state = new SetStateRequest();
// Set the Request Object's Properties
state.State = new OptionSetValue((int)IncidentState.Active);
state.Status = new OptionSetValue((int)incident_statuscode.WaitingforDetails);
// Point the Request to the case whose state is being changed
state.EntityMoniker = caseReference;
// Execute the Request
SetStateResponse stateSet = (SetStateResponse)_serviceProxy.Execute(state);
}
private void CloseIncident(EntityReference caseReference)
{
// Close the Incident
// Create resolution for the closing incident
IncidentResolution resolution = new IncidentResolution
{
Subject = "Case Closed",
};
resolution.IncidentId = caseReference;
// Create the request to close the incident, and set its resolution to the
// resolution created above
CloseIncidentRequest closeRequest = new CloseIncidentRequest();
closeRequest.IncidentResolution = resolution;
// Set the requested new status for the closed Incident
closeRequest.Status = new OptionSetValue((int)incident_statuscode.ProblemSolved);
// Execute the close request
CloseIncidentResponse closeResponse = (CloseIncidentResponse)_serviceProxy.Execute(closeRequest);
}
推荐阅读
- git - 在 Cygwin 中通过 SSH 进行 Git 克隆不提示输入密码,而是输出错误
- ruby-on-rails - 如何为 Rails 5.2 转换 Rails 动态路由
- go - 当端口在.json文件中硬编码时如何使用动态端口?
- php - laravel 自动硬删除
- python - 如何将输入 X 和 y_pred 传递给 keras 中的自定义损失函数?
- javascript - 跟踪不同来源的 iframe 上的焦点事件?
- java - 需要帮助搜索三个文件并打印出相同的公共行
- javascript - 如何使用 React JS 导出多个类组件?
- javascript - 图像在 Android 上消失(React-Native)
- python - 在python上迭代两次时出错