Skip to main content

Notifications

Announcements

No record found.

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?

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,081 Super User 2024 Season 1 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans