Usability is an important consideration in any CRM installation and customization project. A proven method to improve usability is to reduce the number of steps/clicks to get something done. Within Dynamics CRM 4, it takes 3 steps to add a New Case to a Contact, once the Contact has been located:

1. Double-click on a Contact listed in the Contact Grid View. The Contact will be displayed in a new window.

2. Click on Cases within the NavBar.

3. Click on the New Case button.

These steps can be reduced by including a New Case button on the Contact Entities Grid View toolbar. The New Case button simply needs to open a new window and pass the appropriate parameters to the Create Case form. An easy way to find the querystring parameters that need to be passed to the Create Case Form is to view the Browser Navigation Bar. Press Ctrl+N while the form is displayed, to view the url and the querystring parameters. You can also refer to the MSDN documentation on URL Addressable Forms and Views.

Here is the URL to create a new case for a Contact with a GUID of:

http://localhost:5555/MicrosoftCRM/cs/cases/edit.aspx?_CreateFromType=2&_CreateFromId=%7b1120590A-37D0-DC11-AA32-0003FF33509E%7d#

_CreateFromType is set to 2, because the Case is being attached to a Contact.

_CreateFromId is set to the GUID of the contact.

MicrosoftCRM is the name of the CRM instance if running multiple organizations.

The trick is going to be getting the GUID of Contact selected in the Grid. After some web searching I found a Javascript method that can be called to returned all an array of all selected items - getSelected(’crmGrid’). This is not a supported customization, but if it does not work in the next version of Dynamics CRM, the Button could be removed and users would return to using the 3 step method to add a Case to a Contact.

We really only want a single Contact selected when the New Case button is clicked. We use simple Javascript to check the length of the returned array and display appropriate alert messages:

selected_contact = getSelected('crmGrid');

if (selected_contact.length==0)

{alert('A Contact must be selected before a Case can be added.')}

else if (selected_contact.length==1)

{

window.open('/CRMInstancename/cs/cases/edit.aspx?_CreateFromType=2&_CreateFromId='+ selected_contact, 'CreateNewCase','top=100,left=175,width=800,height=600,menubar=no,resizable=yes')}
else
{

alert('A Case can\'t be added to multiple Contacts. Please select a single Contact.')

}

The entire Javascript code block will be compressed to a single line and passed to the Javascript element of a button.

Let’s move on to adding the button to the Contact Grid’s Toolbar. It is always a good idea to export the current ISV.Config file instead of using a stored version. New entities and extensions may have made changed to the ISV.Config - you don’t want to lose these. The button is added to the <Grid> tag for the Contact entity. Replace CRMInstance in the url with the name of your instance.

<ImportExportXml version=”4.0.0.0″ languagecode=”1033″ generatedBy=”OnPremise”>
<Entities>
</Entities>
<Roles>
</Roles>
<Workflows>
</Workflows>
<IsvConfig>
<configuration version=”3.0.0000.0″>
<Root>
<MenuBar>
</MenuBar>
</Root>
<Entities>
<Entity name=”contact”>
<MenuBar>
</MenuBar>
<Grid>
<MenuBar>
<Buttons>

<Button Client=”Web, Outlook” Icon=”/_imgs/ico_16_112.gif” PassParams=”1″ WinMode=”0″
JavaScript=”selected_contact= getSelected(’crmGrid’); if (selected_contact.length==0){alert(’A Contact must be selected before a Case can be added.’)} else if (selected_contact.length==1) {window.open(’/MicrosoftCRM/cs/cases/edit.aspx?_CreateFromType=2&_CreateFromId=%7b’+ selected_contact[0].substr(1,selected_contact[0].length-2) + ‘%7d#’, ‘CreateNewCase’,'top=100,left=175,width=800,height=600,menubar=no,resizable=yes’)} else {alert(’A Case can\’t be added to multiple Contacts. Please select a single Contact.’)};”
>
<Titles>
<Title LCID=”1033″ Text=”Add Case” />
</Titles>
<ToolTips>
<ToolTip LCID=”1033″ Text=”Add Case” />
</ToolTips>
</Button>
</Buttons>
</MenuBar>
</Grid>
</Entity>
</Entities>
</configuration>
</IsvConfig>
<EntityMaps />
<EntityRelationships />
<Languages>
<Language>1033</Language>
<Language>1036</Language>
<Language>1031</Language>
<Language>3082</Language>
</Languages>
</ImportExportXml>

We can now import the ISV.Config customization. Don’t forget to enable the ISV.Config changes

image

Click on Contacts, a New Case button will be displayed on the Grid Toolbar. Test the button by selecting no Contacts, a single Contact or multiple Contacts.

image

Download the ISV.Config file.

    Read More   

Comments

Chris Eakin on 9 July, 2008 at 6:37 pm #

Great Post!

I was able to extend your logic to the Accounts list by adding this to the isv.conf file:

Now I can easily create a Ticket that is specific to an Account.

Whoo-Hoo!


Ian Randall on 29 September, 2008 at 8:16 pm #

Thanks - I need to prompt the user with a ‘do you wish to create a for this new when the parent record is saved… this should do the trick nicely :)


Ian Randall on 29 September, 2008 at 8:21 pm #

My brackets got removed! I meant…

Thanks - I need to prompt the user with a ‘do you wish to create a {child} for this new {parent}?’ when the parent record is saved… this should do the trick nicely
:)


RDC on 12 February, 2009 at 1:55 pm #

Great!

But say that you want to prefill more than one of the new case’s fields. Is there a way to pass more than one value to the edit form?


Post a Comment
Name:
Email:
Website:
Comments: