Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Filter Customer field on Case Form

Posted on by Microsoft Employee

Hi,

In the Customer Field of the Case Card Form, I'd like our users to only be able to choose Accounts (not Contacts) with Relationship Type = "Customer" (so not Leads, Prospects, etc.)
Is there a way to do this?

Kind regards,


Nina

*This post is locked for comments

  • Verified answer
    ajyendra Profile Picture
    ajyendra 1,730 on at
    RE: Filter Customer field on Case Form

    Hi,

    Instead having 2 filters , add to it respective custom filter.

    Change condition and field name as per your need.

    var contactFilter = "<filter type='and'><condition attribute='customertypecode' operator='eq' value='1' /></filter>";
    var accountFilter = "<filter type='and'><condition attribute='accountid' operator='not-null' /></filter>";
    
    Xrm.Page.getControl("customerlookupfield").addCustomFilter(contactFilter, "contact");
    Xrm.Page.getControl("customerlookupfield").addCustomFilter(accountFilter, "account");

    Thanks
    Ajyendra

    if this answer is helpful to you. Please Mark as Verified.
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filter Customer field on Case Form

    Hi Ajyendra,

    Thanks a lot, that answers the first half of my question.

    However, I still do not know how to filter on a field (in my case the custom field Relationship Type) of a field (Customer). Would you have an example of the code for this as well?

    Kind regards,

    Nina

  • Verified answer
    ajyendra Profile Picture
    ajyendra 1,730 on at
    RE: Filter Customer field on Case Form

    Hi ,

    Please Refer that Link:

    https://www.powerobjects.com/blog/2015/11/20/restrict-customer-lookup-to-accounts-or-contacts-in-dynamics-crm/

    Hope it helps

    Thanks

    Ajyendra

    If this answer is helpful to you . Please Mark as Verified.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans