POWEROBJECTS

718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

PartyList fields can be a very powerful component of activities in Dynamics CRM. Otherwise known as the Activity Party, the PartyList controls what you see in the To, From, and CC lookup fields of an activity. Sometimes you need a little more control over the UI/UX surrounding the PartyList! Currently, there is no out-of-the-box method to filter the PartyList fields in CRM 2015, so you have to utilize JavaScript instead. In today’s blog, we will show you how you can filter PartyList fields using JavaScript and the addPreSearch method.

tips-and-tricks

The business requirement we have today filters the PartyList field “Attendees” on a CRM appointment based on the “Regarding” field that is populated on an Account.

Specifically, we want to check the “Regarding” value on an Appointment, and apply the following filtering logic: If the value in “Regarding” is an Account, filter the “Attendees” field to only show Contacts who work at that Account as available options in the Contacts portion of Attendees.

As we mentioned before, there is no out-of-the-box method to filter the PartyList fields in CRM 2015, so we’ll have to utilize JavaScript to achieve our goal instead.

The primary methods we invoke are the addPreSearch method combined with the addCustomFilter method. The actual script is fairly simple and should contain two functions. See below:

Once your scripts are in libraries, add them to the Appointment entity form. In the Form Properties area, we’ll need to call the scripts. We’ll want to call our FilterPartyList function OnLoad of the form, and OnChange of the “Regarding” field:

ControlEventLibraryFunction
FormOnLoadPartyList_Filter LibraryFilterPartyList
Regarding (field)OnChangePartyList_Filter LibraryFilterPartyList

This can be achieved in the Form Editor, in Form Properties. Once deployed and pubished, you’ll want to be sure to test out your work:

1. If an Appointment is without “Regarding” populated, no filtering will be applied to the “Required” field and the user can select Contacts/Accounts freely:

PartyList Fields

When you click the “Regarding” field above, you will see a full list of Contact records to choose from.

PartyList Fields

2. If the Appointment has the “Regarding” field populated with a Contact, the filter will be applied. As you can see in the example below, Susan Burk works at A. Datum Corp.

PartyList Fields
When you click on the “Required” field shown above, and attempt to add a Contact to the PartyList, you will be prompted with a filtered list of Contacts who work at A. Datum Corp.

PartyList Fields

That’s all there is to it! Be sure to check out our blog on using the addPreSearch/addCustomFilter to a regular look-up field and subscribe so you don’t miss any of our great CRM blog content. Did you know that PowerObjects offers a wide variety of education and training classes, including Boot Camps for CRM 2016? Check out all of our events today!

Happy CRM’ing!

Avatar for JoeCRM

JoeCRM

Joe CRM is a CRM superhero who runs on pure Microsoft Dynamics CRM adrenaline. As the face of PowerObjects, Joe CRM’s mission is to reveal innovative ways to use Dynamics CRM and bring the application to more businesses and organizations around the world.