Hello everyone,
In the accounts entity, we have the Territory lookup field. A business unit can cover multiple territories for example (BU A covers: TerA, TerB, BU B covers: TerC, TerD) I want to achieve the below:
So User A that belongs to BU A cannot see the territories of User B that belong to BU B or change the view.
Is it possible to achieve the above scenario? If so, what is the best way of doing it? Can please someone provide an example?
Any help is highly appreciated.
Thank you!
Hi ,
Thank you for your reply and for providing the steps needed.
1. I have created a custom field which is Business Unit that is lookup on the BU table.
2. As you mentioned, I have to retrieve the current user BU. What is the Web API that should be called to retrieve the BU id of the user by using userSettings?
3. After I have the data from point no.2 should I call the Xrm.WebApi retrievemultiplerecords against the territory entity to filter the BU of the user against the territory field that I created?
4. On which event the JS code should be called on form level or field level?
5. Could you please provide a simple sample example? I will also start to prepare the code and post it here and would highly appreciate it if you can assist.
Awaiting your response.
Hi EBMRay,
Unfortunately, you can't filter it through add condition in the lookup view.
If you want to do this, you need use js code and web api.
1. Get the current userId.
2. Retrieve current user with current userId to get the BU id(lookup field).
3. Get all users belong to current user's BU by web api with BU id.
4. Use these users as filter to addCustomFilter() function:
addCustomFilter (Client API reference) in model-driven apps - Power Apps | Microsoft Docs
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156