Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

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

Posted on by 45

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

  • Junius01 Profile Picture
    Junius01 45 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.

  • Verified answer
    Haig Liu Profile Picture
    Haig Liu 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

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,063 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

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans