web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Filtering Lookup

(0) ShareShare
ReportReport
Posted on by

Hi Everyone...I am a beginner in crm .I Just want to know how to filter Lookups based on conditions. For Example If a country is selected then corresponding states related to that country alone should be displayed in the lookup.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Assuming you have lookup for both country and state (which means you have entity for country and state and they are related 1:N), you can simply configure property of state lookup to show it based on the selected country.

    Refer: http://garethtuckercrm.com/2011/03/22/filtered-lookup-approaches-in-crm-2011/

     crmadminassist.com/microsoft-dynamics-crm-dependent-lookups

    Let us know if you are facing any issue

  • Community Member Profile Picture
    on at

    Hi.

    You have to create country lookup field in state entity and create record respectively.

  • Aileen Gusni Profile Picture
    44,524 on at

    Muthu,

    At first, you need to create 2 entities:

    Country and then State

    Then create relationship N:1 State to Country

    After that you must create the relationship for those 2 entities to the entity form you want to put them, like for example account or contact

    Then you can follow Himbap suggestion, using javascript or dependent lookup

    Thanks!

  • Community Member Profile Picture
    on at

    Ya I have created those Entities and This is my java script code but it is not working ...

    function preFilterLookup()

    {

    debugger;

    Xrm.Page.getControl("ccs_state").addPreSearch(function () {

    var stateObject = Xrm.Page.getAttribute("ccs_state").getValue();

    // Get the lookup Object, and extract the Value (ID and Text)

    if(stateObject != null)

    {

    var stateTextValue = stateObject[0].name;

    var stateID = stateObject[0].id;

    // Filter the cities by State

    fetchXml = "<filter type='and'><condition attribute='ccs_state' operator='eq' uiname='" + stateTextValue + "' uitype='ccs_state' value='" + stateID + "' /></filter>";

    // Apply the filter to the field

    Xrm.Page.getControl("new_city").addCustomFilter(fetchXml);

    }

    });

    }

  • Community Member Profile Picture
    on at

    Ya got it....But  I have a small doubt when should we use custom filters...can u just give me any scenarios....

  • Fubar Profile Picture
    2,761 on at

    Use them when dependent lookups are not possible e.g. the value you want to form part of the filter is the value of a picklist, or is sitting on another record.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans