Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Filtered lookups

(0) ShareShare
ReportReport
Posted on by

Hello

I have a entity which contains vehicle data. The columns include vehicle type, number of wheels , vehicle name etc. I have this linked to another table using a lookup relationship. So a support request can relate to a specific vehicle. Now this all works fine. The problem that i am having is that the default lookup view is not good at all. we have thousands of vehicles in our entity and using the standard lookup is unfeasible. 

The requirement that i have is to make a sort of a progressive menu to pick the vehicle. For example we have a drop down that has all vehicle types. Then when you select the vehicle type, the second drop down which would be number of wheels is only populated with the vehicles of that type. So once you select 4 wheels , it will show only vehicle names with 4 wheels and of type that you picked in the third drop down and so on. I am not sure how to create this effect with dynamics. i know how i would do it with Microsoft access or other databases.  

Essentially i would have to on load run a query to populate the option values of the first drop down with (select * vehicle types from VehicleTable) and on the on update event of the drop down , i just run a query to populate the second drop down list options eg  select * from vehicleTable where vehicle type = my vehicle type. and so on. 

I am not sure how i can create this effect with dynamics. Can someone provide me with some insight as to what direct i need to take to generate this effect?

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Filtered lookups

    Hi,

    First of all when user type a value on a lookup field the field should automatically populate with the selection.

    If it does not, please check in you System View the Quick Find View, and make sure that the column that you want your user to find the values on is in the Add Find Columns list.

    Regarding your query:

    You can use the following code to get the Guid out of a lookup:

    var lookup = Xrm.Page.getAttribute(fieldname).getValues();

    var lookupId = lookup[0].id;

    Add that to your filter instead of the name Mazda, and you should be able to get the results that you are looking for.

  • RE: Filtered lookups

    This is the correct direction. I just have another related question.

    I am trying to build my query but the make of the vehicle is a lookup field.

    so i need to essentially say

    "<filter type='and'><condition attribute='new_make' operator='eq' value='mazda' /></filter>"

    but the make is a lookup field so it expects a guid. but i want my users to be able to type mazda and let them find it .the name mazda is in the database as its name, but i somehow need to specify it by name even though its a lookup field

  • Verified answer
    tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Filtered lookups

    What are you going to need in this scenario are filtered lookups. You can find plenty of examples over the Internet, for example:

    www.magnetismsolutions.com/.../crm-2013-javascript-lookup-filtering-using-addcustomfilter

    Basically you can att such javascript function for every lookup. When user clicks on the lookup, to function is fired and you can check the values from the other lookups and filter the results accordingly. Of course you need to develop this using JavaScript on the form, which is not a database thing if you never done that, but the link I provided is a good starting point (but learning JS if you never wrote anything in this language is quite a separate challenge)

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans