Adding Case Resolution and CaseFields to the Case Form in Dynamics CRM
In Dynamics CRM, when the Case is resolved a new form is required to be filled in which captures the resolution items as shown in the image below:
These fields are hard to get access to as they are stored in a hidden Entity called IncidentResolution. If you want to use the Case Resolution or Case Remarks values on a workflow or view or form, you will need to copy the values to case Entity fields using a plugin when the case is resolved.
The steps to do so are provided below:
- Create 2 new fields on Case entity : new_CaseResolution and new_CaseRemarks
- Write a plugin on the creation of IncidentResolution entity and copy the values to Case entity fields.
- Register the plugin as shown in the image below:
Source code for plugin is given below:
//Run Plugin
var targetEntity = plugin.TargetEntity.ToEntity<IncidentResolution>();
if (targetEntity.IncidentId != null)
{
Incident caseToBeUpdated = new Incident();
caseToBeUpdated.Id = targetEntity.IncidentId.Id;
plugin.Tracer.Trace($”Case ID: {caseToBeUpdated.Id}”);
//capture the Case Resolution Fields
if (!string.IsNullOrEmpty(targetEntity.Subject))
{
caseToBeUpdated.new_CaseResolution = targetEntity.Subject;
plugin.Tracer.Trace($“Case Resolution: { caseToBeUpdated.new_CaseResolution}“);
}
if (!string.IsNullOrEmpty(targetEntity.Description))
{
caseToBeUpdated.new_CaseRemarks = targetEntity.Description;
plugin.Tracer.Trace($”Case Remarks: { caseToBeUpdated.new_CaseRemarks}”);
}
plugin.Tracer.Trace(“Updating Case”);
service.Update(caseToBeUpdated);
}
2,378 total views, 1 views today