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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Polymorphic Lookup Filter

(2) ShareShare
ReportReport
Posted on by 8
Hello Community,
 
I'm having a problem with a filter inside a polymorphic lookup inside a quick create form.
 
- My quick create form has 2 fields (Field A and Field B), where field A is an OptionSet (option "User" and option "Contact") and field B is a polymorphic lookup (we can have system users and contacts);
- I put an addOnChange in Field A, that calls my filterFunction;
- When field A is with the value "User": I need to filter the polymorphic lookup with only system users;
- When field A is with the value "Contact": I need to filter the polymorphic lookup with the contacts that are linked with an account (I have this account GUID to pass inside the Fetch)
 
I tried somethings, but I couldn't solve this problem.
 
Thanks a lot!!
I have the same question (0)
  • Verified answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    Polymorphic Lookup Filter
    Hello User,
     
    Please refer below article which will help you to resolve your issue.
     
     
    Thank you,
    Amit Katariya
  • GJ-05011853-0 Profile Picture
    8 on at
    Polymorphic Lookup Filter
     
    I did exactly as the arcticle but, is there anyway to remove the other relationship inside the lookup?



    For example, when I need only to show Users, not show the "contacts" results, and when it needs to show Contacts, not show "systemusers" results.
  • Suggested answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    Polymorphic Lookup Filter
    Hello User,
     
    If you have added whole code from article then it will show both things. it is because it is having custom filter for contacts as well as system user entity.
     
    If you want to filter lookups as per contacts then use below fetch XML edit it as needed and then use add custom filter.
     
    var contactFilter = "<filter type='and'><condition attribute='firstname' operator='eq' value='Mira' /></filter>";
     
    formContext.getControl("new_polymorphiclookupid").addCustomFilter(contactFilter, "contact");
     
    For system user use below format but with your respective XML conditions.
     
    var userFilter = "<filter type='and'><condition attribute='firstname' operator='eq' value='Mira' /></filter>";
     
    formContext.getControl("new_polymorphiclookupid").addCustomFilter(userFilter, "systemuser");

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 241

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 164 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 153

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans