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
Thank you Xavier Monin
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
#ManoVerse 101
Siv Sagar 93 Super User 2025 Season 2
Martin Dráb 66 Most Valuable Professional