Greetings experts,
I'm trying to use a plugin that opens an incident, updates a value and closes again. I'm using the following code for this:
--
//Reopen Case
OptionSetValue opencasestatedcode = new OptionSetValue();
opencasestatedcode.Value = 0;
OptionSetValue opencasestatuscode = new OptionSetValue();
opencasestatuscode.Value = 1;
casentity["statuscode"] = opencasestatuscode;
casentity["statecode"] = opencasestatedcode;
service.Update(casentity);
//Update Total Time
casentity["new_total_time"] = 60;
service.Update(casentity);
// Create the incident's resolution.
var incidentRes = new IncidentResolution
{
Subject = "Resolved Sample Incident",
IncidentId = new EntityReference(Incident.EntityLogicalName, (Guid)casentity.Attributes["incidentid"])
};
// Close the incident with the resolution.
var closeIncidentRequest = new CloseIncidentRequest
{
IncidentResolution = incidentRes,
Status = new OptionSetValue(5)
};
_serviceProxy.Execute(closeIncidentRequest);
--
But during the execution, it throws the following error: System.NullReferenceException: Object reference not set to an instance of an object
Any ideas about what am I doing wrong?
*This post is locked for comments