As of Dynamics 365 version 9.0, it's now possible to achieve this functionality using supported code. For this reason I've completely rewritten this solution using supported lookup objects and Web API. I've maintained the orginal unsupported source code for anyone not yet on v9.0. I've also referenced the blog posts containing the code for earlier versions of CRM too. See below for links to source code and usage instructions for each.
- Dynamics 365 v9.0 (supported code)
- Dynamics CRM 2016 (unsupported code)
- Dynamics CRM 2015 & 2013 (unsupported code)
- Dynamics CRM 2011 UR12 (unsupported code)
- Dynamics CRM 2011 (unsupported code)
- Dynamics CRM 4.0 (unsupported code)
Created by Paul Nieuwelaar - @paulnz1
Sponsored by Magnetism Solutions - Dynamics CRM Specialists