Hi everyone,
Could anyone please share sample java script code to hide a tab based on the current users custom security role? E.g. if the security role name is "Administrator", hide a specific tab.
Best regards,
Hi,
You can use this javascript:
/* Hide "mytab" tab if the user is an administrator * Register this event handler on form load. * Check the "Pass execution context as first parameter" checkbox. */ function onLoad(execCtx) { const formCtx = execCtx.getFormContext(); const roleName = "System Administrator"; const isAdmin = Xrm.Utility.getGlobalContext().userSettings.roles.get(r => r.name == roleName); if (isAdmin) { formCtx.ui.tabs.get("mytab").setVisible(false); } }
To learn more: learn.microsoft.com/.../usersettings
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,134 Super User 2024 Season 2
Martin Dráb 229,928 Most Valuable Professional
nmaenpaa 101,156