Setting Entity Lookup Defaults on Party Lists in Dynamics CRM 2016

The activity party list is a great feature allowing multiple types of records to be added to the same field. However, sometimes a company’s business rules require a specific type of record for a certain field. For example, the ‘Call To field’ on a Phone Call. This field allows you to select an Account as a recipient and is the first entity you are provided with to choose from. As Phone Calls are made to a specific person, your company may not want Accounts as an option for Users to select from. In this case, you would want to restrict what entities were allowed in the lookup types. This is easily accomplished in CRM 2013 using Javascript. To do this you would need two functions. The first is a supported method to add the filter to the field:

Xrm.Page.getControl(“to”).addPreSearch(addFilter);

The second function uses unsupported methods, but does allow us to apply our filters where 2, 4, and 8 are the entity type codes for Contact, Lead, and User respectively:

Function addFilter() {

                  document.getElementById.(“to_i”).setAttribute(“defaulttype”, “2, 4, 8”);

                  document.getElementById.(“to_i”).setAttribute(“lookuptypes”, “2, 4, 8”);

                  document.getElementById.(“to_i”).setAttribute(“lookuptypenames”, “contact:2:Contact, lead:4:Lead, systemuser:8:User”);

}

Unfortunately, the getElementById does not resolve in CRM 2016. This ends up causing the lookup icon for the field not to respond at all. Thankfully there is a way to accomplish this record type filtering in CRM 2016. I cannot find any documentation explicitly stating the use of this method, but it does work and appears to be supported. This also reduces the script from multiple lines of code to just one line. For this method you only need to define the entity types you would like to restrict the field to:

Xrm.Page.getControl(“to”).getAttribute().setLookupTypes([“contact”,”lead”,”systemuser”]);

Want to learn more or have questions? Reach out to Scott by emailing [email url=”info@ktlsolutions.com” class=””]info@ktlsolutions.com[/email] or calling our main line at 301.360.0001.


SCOTT FLORANCE | Business Software Consultant

Scott Florance is one of the CRM Consultants at KTL, and has proven his value as a member of the team since September 2013. Whether implementing a new CRM organization or adding to existing configurations, Scott has engaged clients with a positive and enthusiastic demeanor to help them meet their organizational needs. With six plus years of experience, Scott is familiar with CRM as both a power user and administrator. Scott received his Bachelor’s Degree in Business Administration from the University of Central Florida. He is a Microsoft Certified Technology Specialist for Dynamics CRM, as well as a Certified Scribe Technician.

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email

Related Posts