首页 > 解决方案 > 在 MS CRM 2015 错误消息中更新实体时

问题描述

我在 crm 2015 中有一个事件表。在 spme 操作之后,事件实体变得被动。在我的数据库中,被动事件是通过查看状态和状态列来理解的。如果事件是被动的,则状态码变为 1,状态码变为 5。

事后变得被动。我想对那个事件实体做些事情。

作为操作员,我想更改状态和状态以激活事件。(状态=0,状态=1)

如果我成功了,我想将 new_anketgonderildi 字段(位字段)更新为 true。然后再次使事件被动并更新实体。

但是更新实体时出现错误。

这个案子已经解决了。关闭并重新打开案例记录以查看更新。

我意识到如果事件处于活动状态,我可以更改 new_anketgonderildi 字段。当事件处于被动状态时我无法改变。要更改位值字段,我必须激活事件更改位字段,然后再次停用事件。

我怎样才能实现这种情况?代码 在此处输入图像描述

标签: c#crm

解决方案


这就是 CRM 的工作方式。有许多实体(包括案例/事件)一旦变为非活动(被动)就无法再编辑。

您将需要;

  1. new_anketgonderildi在关闭案例之前更新。
  2. 重新激活已关闭的案例,更新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);
}

推荐阅读