Dynamics CRM 2011 – Replace case resolution with dialog

NOTE: There are probably better ways of doing this (e.g.  a ribbon editor)

Problem: CRM case resolution doesn’t allow customisation
Solution: Replace case resolution with custom dialog, to allow for full customisation/process.
Solution Details: Client side JavaScript and solution (customization.xml) modification
Issue with solution: Doesn’t check for any open activities. Can probably find code online which you can wrap around the code below to warn uses to close activities beforehand.

  • Create javascript web resource, call it “CaseResolutionDialog” (or anything you like)
  • Use the following code:
</p>
<p>function ResolveCaseDialog(dialogID, typeName, recordId)<br />
{<br />
var serverUri = Mscrm.CrmUri.create('/cs/dialog/rundialog.aspx');</p>
<p>window.showModalDialog(serverUri + '?DialogId=' + dialogID + '&amp;EntityName=' + typeName + '&amp;ObjectId=' + recordId, null, 'width=615, height=480,resizable=1,status=1,scrollbars=1');</p>
<p>window.location.reload(true);<br />
Xrm.Page.data.entity.save('saveandclose');<br />
}</p>
<p>

Note: You can remove the saveandclose if you want.

  • Create a new dialog for case/incident, give it a name and save it (Use a name such ‘Case Resolution’
  • Create a solution (or modify an existing solution), add the Case/Incident entity, add the web resource (JS file) and add the dialog
  • Export solution (Unmanaged)
  • Extract the solution with your favourite extract tool (Goodbye RinRar, hello 7Zip)
  • Open ‘Customizations.xml’ with your favourite text editor (Hello NotePad++)
  • Search for your dialog name (‘Case Resolution’)
  • Should see the following code (GUID details will be different)
&lt;Workflows&gt;<br />
&lt;Workflow WorkflowId="{e7f23fe6-9a5a-4128-aacf-2ed681fa75ff}" Name="Case Resolution"&gt;<br />
&lt;XamlFileName&gt;/Workflows/CaseResolution-E7F23FE6-9A5A-4128-AACF-2ED681FA75FF.xaml&lt;/XamlFileName&gt;<br />
&lt;Type&gt;1&lt;/Type&gt;<br />
&lt;Subprocess&gt;0&lt;/Subprocess&gt;<br />
&lt;Category&gt;1&lt;/Category&gt;<br />
&lt;LanguageCode&gt;1033&lt;/LanguageCode&gt;<br />
&lt;Scope&gt;1&lt;/Scope&gt;<br />
&lt;OnDemand&gt;1&lt;/OnDemand&gt;<br />
&lt;TriggerOnCreate&gt;0&lt;/TriggerOnCreate&gt;<br />
&lt;TriggerOnDelete&gt;0&lt;/TriggerOnDelete&gt;<br />
&lt;AsyncAutodelete&gt;0&lt;/AsyncAutodelete&gt;<br />
&lt;IsCustomizable&gt;1&lt;/IsCustomizable&gt;<br />
&lt;PrimaryEntity&gt;Incident&lt;/PrimaryEntity&gt;<br />
&lt;/Workflow&gt;<br />
&lt;/Workflows&gt;
  • Copy the GUID which are all capitalised (e.g.: E7F23FE6-9A5A-4128-AACF-2ED681FA75FF)
  • search for ‘<entity Name=”Incident”>’
  • Scroll down to the point you see:
&lt;RibbonDiffXml&gt;<br />
&lt;CustomActions&gt;<br />
&lt;/CustomActions&gt;

It HAS to be within the incident/case entity (Basically, before the </entity> tag

  • Replace the whole ribbon section with the below code:
<p>&lt;RibbonDiffXml&gt;<br />
&lt;CustomActions&gt;<br />
&lt;/CustomActions&gt;<br />
&lt;Templates&gt;<br />
&lt;RibbonTemplates Id="Mscrm.Templates"&gt;&lt;/RibbonTemplates&gt;<br />
&lt;/Templates&gt;<br />
&lt;CommandDefinitions&gt;<br />
&lt;CommandDefinition Id="Mscrm.Form.incident.Resolve"&gt;<br />
&lt;EnableRules&gt;<br />
&lt;/EnableRules&gt;<br />
&lt;DisplayRules&gt;<br />
&lt;DisplayRule Id="Mscrm.CanChangeIncidentForm" /&gt;<br />
&lt;DisplayRule Id="Mscrm.IncidentIsActive" /&gt;<br />
&lt;/DisplayRules&gt;<br />
&lt;Actions&gt;<br />
&lt;JavaScriptFunction FunctionName="ResolveCaseDialog" Library="$webresource:ncp_ResolveCaseDialog" &gt;<br />
&lt;!-- dialogID, typeName, recordId --&gt;<br />
&lt;StringParameter Value="E7F23FE6-9A5A-4128-AACF-2ED681FA75FF" /&gt;<br />
&lt;StringParameter Value="incident" /&gt;<br />
&lt;CrmParameter Value="FirstPrimaryItemId" /&gt;<br />
&lt;/JavaScriptFunction&gt;<br />
&lt;/Actions&gt;<br />
&lt;/CommandDefinition&gt;<br />
&lt;/CommandDefinitions&gt;<br />
&lt;RuleDefinitions&gt;<br />
&lt;TabDisplayRules /&gt;<br />
&lt;DisplayRules /&gt;<br />
&lt;EnableRules /&gt;<br />
&lt;/RuleDefinitions&gt;<br />
&lt;LocLabels /&gt;<br />
&lt;/RibbonDiffXml&gt;</p>
<p><span style="line-height: 1.5em;">

  • Replace the GUID (Above) with the GUID from your workflow/dialog.
  • Save the ‘Customizations.xml’
  • Re Import the ‘Customizations.xml’ file back into the solution file
  • Import the solution file back into CRM
  • Publish the solution
  • Open a case
  • Resolve the case (Dialog should now appear)

As this should now launch the resolution dialog, feel free to make the rest of the logic your own.

Jason
Jason
I do things in the clloouuudddd