CRM 2013 更新事件解决实体的状态代码

CRM 2013 to update statecode of Incident Resolution Entity

我对 CRM 的这一部分还很陌生。我想设置事件解决实体的 StateCode 字段。

我正在尝试以下方式 -

IncidentResolution res = new IncidentResolution();
res.IncidentId = new EntityReference();
res.IncidentId.LogicalName =Incident.EntityLogicalName;
res.IncidentId.Id = new Guid(row["id"].ToString());
res.StateCode = new OptionSetValue((int)IncidentResolutionState.Completed)); //This Following gives the error as System.Nullable<IncidentResolution.StateCode> cannot be assigned to--It is readonly.
CloseIncidentRequest req = new CloseIncidentRequest();
req.IncidentResolution = res;
req.Status = new OptionSetValue();
req.Status.Value = 5; // Problem Solved
service.execute(req);

我面临的问题是为事件解决实体设置 StateCode 属性。 任何帮助,将不胜感激。 提前致谢

您不需要设置IncidentResolution的StateCode,只需设置CloseIncidentRequest的Status:

IncidentResolution res = new IncidentResolution
{
    Subject = "Resolved Sample Incident",
    IncidentId = new EntityReference(Incident.EntityLogicalName, new Guid(row["id"].ToString()))
};

// Close the incident with the resolution.
CloseIncidentRequest req = new CloseIncidentRequest
{
    IncidentResolution = res,
    Status = new OptionSetValue(5)
};
service.execute(req);