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

时间:2015-03-25 05:46:25

标签: dynamics-crm-2011 dynamics-crm dynamics-crm-2013

我对这部分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属性。 任何帮助,将不胜感激。 在此先感谢

1 个答案:

答案 0 :(得分:3)

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

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);