【问题标题】:CRM SDK to re-open incident and close with same statusCRM SDK 重新打开事件并以相同状态关闭
【发布时间】:2016-12-13 18:18:02
【问题描述】:

我可以检索与已关闭事件相关的状态并重新打开该事件。我无法理解的是如何使用以前的状态时 我重新关闭事件。我想以重新打开之前使用的相同状态关闭事件。

//get the incident
incident = _service.Retrieve(incident.LogicalName, _incidentId, attributes);
//get the status code
Int32 tmp_status = Convert.ToInt32(incident["statuscode"]); //DOES NOT WORK
//open incident
SetStateRequest state = new SetStateRequest();
state.EntityMoniker = new EntityReference("incident", _incidentId);
state.State = new OptionSetValue(0);
state.Status = new OptionSetValue(4);
SetStateResponse stateSet = (SetStateResponse)_serviceProxy.Execute(state);

//close incident
var incidentResolution = new IncidentResolution
{
    Subject = "Incident Resolved",
    IncidentId = new EntityReference(Incident.EntityLogicalName, _incidentId)
};
var closeIncidentRequest = new CloseIncidentRequest
{
    IncidentResolution = incidentResolution,
    Status = new OptionSetValue(tmp_status) //Can't get the syntax of how to use tmp_status
};

_serviceProxy.Execute(closeIncidentRequest);

【问题讨论】:

    标签: c# sdk dynamics-crm crm


    【解决方案1】:

    尝试换行

    Int32 tmp_status = Convert.ToInt32(incident["statuscode"]);
    

    带线

    Int32 tmp_status = incident.GetAttributeValue<OptionSetValue>("statuscode").Value;
    

    【讨论】:

      猜你喜欢
      • 2015-07-10
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      相关资源
      最近更新 更多