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

Notifications

Announcements

No record found.

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,086 Moderator on at

    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

    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

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 45

#2
Martin Dráb Profile Picture

Martin Dráb 38 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans