Hi Everyone,
I am trying to Load a tab based on the Security role. Can anyone please help?
I tried using the below code on the form onLoad but no luck.
Can anyone please correct me?? or provide a better solution.
For below code; i used onload function "leadFormCustomization.customEditAccess"
var leadFormCustomization = { customEditAccess: function (execContext) { debugger; var formContext = execContext.getFormContext(); var userSettings = Xrm.Utility.getGlobalContext().userSettings; //Get Security Roles of the current User var securityRoles = userSettings.securityRoles; //Below is the GUID of the Security Role "CustomEditAccess" var securityRoleId = "7b54873B06-A234-EA11-A812-000D3A53014B"; for (i = 0; i < securityRoles.length; i ) { //If current User contains the Required Security Role if (securityRoles[i].toUpperCase() == securityRoleId.toUpperCase()) { Xrm.Page.ui.tabs.get("tab_2").setFocus() }}}}
Thank you in advance.
Hi, can you please take a look a look at this issue? It is similar to this one.
community.dynamics.com/.../show-sp-documents-subgrid-based-based-on-security-role
Hi,
We should use getGlobalContext.userSettings (Client API reference) in model-driven apps - Power Apps | Microsoft Docs roles which have name and you can compare with name instead of GUID as it is readable information for future tracking and future identification of issue quickly. Microsoft deprecated securityRoles method so we must use the userSettings.roles method to avoid any issue.
Please find more information as below about userSettings.roles:
Returns a collection of lookup objects containing the GUID and display name of each of the security role assigned to the user and any security roles assigned to a team that the user is associated with. This method is supported only on Unified Interface.
Microsoft introduced this method in UCI and it should be used as Microsoft advised as below:
Returns an array of strings that represent the GUID values of each of the security role or teams that the user is associated with.
Deprecated; use userSettings.roles instead to view the display names of security roles or teams along with the ID.
So, please use userSettings.roles method and compare with name instead of ID. Thank you.
Best Regards,
Mobeen Mohsin
Thank you so much, Mehran. It's working fine. Appreciate your help! :)
Hello
I think you made a very, very small mistake!
Note this line:
var securityRoleId = "7b54873B06-A234-EA11-A812-000D3A53014B"
Looks like you copied the GUID incorrectly and added 7b in the first one!
True: "54873B06-A234-EA11-A812-000D3A53014B"
best regards.
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156