cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Lookup filter based on different lookup field

Hi there,

 

I have 2 custom made entities, Company and Contact Person. 

Both have a lot of custom fields, but its about 2 specific ones.

I have a field Company which is a lookup that shows a list of companies, which completely fine.

But I have a field Reports To which is a lookup that shows a list of contact persons, except it shows all contact persons while this should be all contact persons of the company. Since it would be weird to display a list of people that don't belong to that company.

 

Is it possible to display a list of Contact Persons of the Selected Company for the lookup field Reports To?

 

Thanks in advance!

 

Edit 1:

 

I forgot to mention that I would like to achieve this in a Model Driven App.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @Billy_C ,

 

You will need to use JavaScript to achieve the goal.

However, I find some similar needs in Dynamics 365 forum such as:

https://www.arbelatech.com/insights/blog/how-to-filter-lookups-without-custom-code-in-dynamics-365-c... ;

https://community.dynamics.com/365/sales/f/dynamics-365-for-sales-forum/396643/filter-sub-grid-looku... 

 

Please reference and may there be a solution for you.

 

Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it.

View solution in original post

3 REPLIES 3
Highlighted
Microsoft
Microsoft

Hi @Billy_C ,

 

Do you want to filter the “Reports To” Combo Box in which contains the items of contact persons belong to the corresponding company?

What data source are you working with, CDS or others? Assuming it is CDS data source, are you working on a third entity form with fields of “Reports To” and “Companies”? Is there a one-to-many relationship between entities “Company” and “Contact Person”?

 

I assume that you are working with CDS and on the third entity name “Reports”, and there is a one-to-many relationship of the two entities which means Contack Person entity with a LookUp field “Company” related to Company entity. Please follow below steps.

 

1. Set the companies Combo Box Items to “Company” eneity;

2. Set the contact person Combo Box Items to:

 

Filter(‘Contact Person’, Company.CompanyName = CompanyComboBox_DataCardValue.Selected.CompanyName)

 

 

The key point is that you need a one-to-many relationship between “Company” entity and “Contact Person” entity, and the third entity with the two LookUp fields related to thus two entities.

 

Create One-to-Many relationship please refer to the official doc:

Create and edit One-to-many or Many-to-one entity relationships 

 
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it.
Highlighted

Hi @v-jefferni ,

My apologies but I forgot to mention that I am trying to achieve this in a Model Driven App.

So I am indeed using CDS, there I only have 2 custom-made entities Contact Person and Company.
Contact Person has a lookup field for Company which is 1 Companies to many Contact Persons.
Contact Persons also has a lookup field "Reports to" which is many Contact Persons to 1 Contact Person.
Now I would like to filter the "Reports to" lookup field so only Contact Persons show up from the selected Company.

So if a user is from Company "Google" and he clicks the reports to field it only shows users from the Company "Google".

My apologies for the inconvenience

Highlighted

Hi @Billy_C ,

 

You will need to use JavaScript to achieve the goal.

However, I find some similar needs in Dynamics 365 forum such as:

https://www.arbelatech.com/insights/blog/how-to-filter-lookups-without-custom-code-in-dynamics-365-c... ;

https://community.dynamics.com/365/sales/f/dynamics-365-for-sales-forum/396643/filter-sub-grid-looku... 

 

Please reference and may there be a solution for you.

 

Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (14,076)