This old chestnut cropped in up one of my projects recently – is an often requirement to replace the free-text MSCRM Country field with a drop-down list such that users can select a particular country and so avoid incorrect/ambiguous typing that makes reporting and analytics’s difficult. (England/UK/Britain being a good example where the same real-world value could be accidently separated in reports)
Changing this behaviour in MSCRM can be tricky as this is a change to the fundamental Address Handling behaviour in MSCRM – such that several places in MSCRM must be customised to support the requirement. As such I would usually try and steer clients away from this requirement due to weighting up the customisation required versus the benefits, as incorrect typing can easily be corrected as a manual process via Bulk Updates.
However this can still be a useful option for improving the User Experience for users of a CRM Solution in certain incidences, and so this post aims to describe how this drop-down Country selection can be implemented in MSCRM with reference to populating longer sets of Picklist options on multiple entities in MSCRM and how this can be achieved without re-keying the full list for each entity.
1. Create a Country Picklist and add this to the Account form
This field can then be added to the Account form alongside the existing current system field for Country.
crmForm.all.address1_country.DataValue = crmForm.all.new_country.SelectedText; crmForm.all.address1_country.ForceSubmit = true;
crmForm.all.address1_country_c.style.visibility = 'hidden'; crmForm.all.address1_country_d.style.visibility = 'hidden';
4. Add the list of Country Picklist values, there is a great online tool provided by Mario Raunig’s blog on how to do this in a easier fashion than the normal method in MSCRM – particularly as we will often need to add this list of Countries for multiple entities (Lead, Account, Address etc) and that this XML Generator comes with a template for list of Countries.
Using this tool, we can export the Entity XML in the usual fashion and unzip to then edit the XML file manually in Visual Studio – we can then run a Find for the ‘new_country’ field that we created earlier:
We can then paste in the XML generated to populate our list of countries for the field.
Saving the XML and moving back into the ZIP file, we can import back into MSCRM to populate the list of countries into the ‘new_country’ picklist field. The entity can then be published to affect the drop-down.
NOTE: I believe MSCRM v5.0 will be incorporating the concept of System-wide Picklists where the same list can be used across multiple entities, this should limit the problem of recreating large picklists for multiple entities to keep the mappings between consistent. However in the meantime and for v4.0 solutions this process of pasting the Options list into the Entity XML is a useful technique.
This earlier form-scripting allows us to preserve this functionality without being forced to add additional customisation to cater for the new Country Drop-down field we have added.
Word of warning for this approach however, the population of the standard County field is being done via Client-side Java Scripting and so will not be populated in the same fashion for any Accounts created via Workflow or Data Migration.
This is a simple customisation but can (with some caveats) be useful for improving the CRM User Experience.