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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How do I filter User Lookup field based on the users being a member of a specific team in a model-driven app?

(0) ShareShare
ReportReport
Posted on by 53

Hello everyone

I have a user Lookup field on my Account entity. I have a model-driven app with the Account main form having this lookup field on it.
Currently, all users in the database are shown. However, I only want to show the users that are part of a specific team (named "Account managers").

pastedimage1670688901669v1.png

We write our scripts in Typescript and add the generated javascript code to my solution using XrmToolbox.
I have already made filters based on properties, but never based on relations.

The Typescript code I'm currently using looks like this:

pastedimage1670689100052v2.png

This code gets executed on the OnLoad event of the form. This code doesn't work.
The relation between a user and team has not been customized. Does anyone know how to filter correctly on team?

This seems like it would be something many developers may have had to do already in the past, which is why I'm asking here.


Thanks in advance.

Junius

I have the same question (0)
  • Verified answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: How do I filter User Lookup field based on the users being a member of a specific team in a model-driven app?

    if you need to filter by team why you filter by businessunitid (that points to Business Unit)? create the filter fetchxml with FetchXML Builder first and check if you are able to retrieve the correct data, after apply the filter to the script

  • Verified answer
    Haig Liu Profile Picture
    Microsoft Employee on at
    RE: How do I filter User Lookup field based on the users being a member of a specific team in a model-driven app?

    Hi Junius01,

    Have you tried out-of-the-box functionality?

    For example, you can customize the default view for the lookup column and then uncheck that the "Allow users to change view":

    pastedimage1670814365501v2.png

    pastedimage1670814448310v3.png

    pastedimage1670814159282v1.png

    You can also create a new lookup view: https://www.forvis.com/article/2022/10/customize-lookup-views-in-microsoft-dynamics-365-crm

  • Junius01 Profile Picture
    53 on at
    RE: How do I filter User Lookup field based on the users being a member of a specific team in a model-driven app?

    Thank you for your response. I have taken your idea, and instead made a custom view in the interface (rather than using code to create one), and used that similarly to how you showed me how I could use the user lookup view.

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 271

#2
Sohaib Cheema Profile Picture

Sohaib Cheema 97 User Group Leader

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 83 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans