Set “Look For” for particular entities in Multi-entity Lookup Field like party List

What is the Issue?

Developers got requirement once in his development career to set the lookup value with only some particular entities like he only needs “users”, “contacts” and restrict other entity’s records to be selected. But he/she have to implement this for some conditions like on change of some field value. But this kind of lookup always shows all the entities in lookup.

The Reason-

This lookup field shows all the entities as it’s default OOB behavior of the multi-entity Lookup (Party List).

 Solution-

You can handle this situation with the help of client side scripting (JavaScript).

Lets have Example-

I want to show only “Contact” and “User” records in “To”,”Cc” and “Bcc” fields (Party List) of Email Entity depending on “Email Behavior” option set field value.

SetLookupForEx1

I have 2 conditions here –

  1. Default E-Mail : should show all the entities records in lookup field as default behavior of field.
    SetLookupFor1
  2. E-mail To Contact or Users Only: should show only “Contact” and “User” entities records in lookup field and all others should be hidden.
    SetLookupFor3

Lets do it with Javascript here-

SetLookupFor2

Add function “filterOnLoad” at locations-
1. “onLoad” event of form with “Pass execution Context as first Argument” checked.
2. “onChange” event of “EMail Behavior” field with “Pass execution Context as first Argument” checked.

Publish your customization and here its done…

Please Note : for “From” field has different behavior than these all above fields. “From” field is lookup/PartyList for only “Users” and “Queues”.
SetLookupFor4

 

You can refer My other blog post related to this one – Filter Required/Regarding (partylist data type) fields…

Hope this will help you.

Enjoy MS CRM!!!

One thought on “Set “Look For” for particular entities in Multi-entity Lookup Field like party List

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s