首页 文章

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

提问于
浏览
0

我对这部分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 回答

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

相关问题