Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:17:07+00:00 2026-06-14T17:17:07+00:00

I have 2 issues. First issue: Trying to hide OOB button in subgrid(Ribbon), based

  • 0

I have 2 issues.

First issue: Trying to hide OOB button in subgrid(Ribbon), based on user role(by calling javascript). Is it possible?

Second issue: Hiding OOB button is not possible through “enablerule”javascript, so alternative I tried to disable button by using “enablerule”/javascript. Here is following code which reflects above. Still is NOT working, but for main form Ribbon button, the below code is working.

Can anyone please help me?

<Groups Id="Mscrm.SubGrid.quote.MainTab.Groups">
                        <Group Id="Mscrm.SubGrid.quote.MainTab.Management" Command="Mscrm.Enabled" Sequence="10" Title="$Resources:Ribbon.HomepageGrid.MainTab.Management" Description="$Resources:Ribbon.HomepageGrid.MainTab.Management" Image32by32Popup="/_imgs/ribbon/newrecord32.png" Template="Mscrm.Templates.Flexible2">
                          <Controls Id="Mscrm.SubGrid.quote.MainTab.Management.Controls">
                            <Button Id="Mscrm.SubGrid.quote.NewRecord" ToolTipTitle="$Resources(EntityDisplayName):Ribbon.SubGrid.MainTab.New" ToolTipDescription="$Resources(EntityDisplayName):Ribbon.Tooltip.New" Command="Mscrm.NewRecordFromGrid" Sequence="10" LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.MainTab.New" Image16by16="/_imgs/ribbon/NewRecord_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1" />
                            <Button Id="Mscrm.SubGrid.quote.AddNewStandard" Command="Mscrm.AddNewRecordFromSubGridStandard" Sequence="20" LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew" Alt="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew" Image16by16="/_imgs/ribbon/NewRecord_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1" ToolTipTitle="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipTitle" ToolTipDescription="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipDescription" />
            </Controls>
        </Group>



     <CommandDefinitions>
              <CommandDefinition Id="Mscrm.AddNewRecordFromSubGridStandard">
                <EnableRules>
                  <EnableRule Id="new.quote.EnableRule2.EnableRule" />
                </EnableRules>
                <DisplayRules>
                  <DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
                  <DisplayRule Id="Mscrm.AppendToPrimary" />
                  <DisplayRule Id="Mscrm.CreateSelectedEntityPermission" />
                  <DisplayRule Id="Mscrm.AppendSelected" />
                  <DisplayRule Id="Mscrm.HideAddNewForChildEntities" />
                </DisplayRules>
                <Actions>
                  <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addNewFromSubGridStandard" Library="/_static/_common/scripts/RibbonActions.js">
                    <CrmParameter Value="SelectedEntityTypeCode" />
                    <CrmParameter Value="PrimaryEntityTypeCode" />
                    <CrmParameter Value="FirstPrimaryItemId" />
                    <CrmParameter Value="PrimaryControl" />
                  </JavaScriptFunction>
                </Actions>
              </CommandDefinition>


           <EnableRule Id="new.quote.EnableRule2.EnableRule">
                <CustomRule FunctionName="IsUserRoleAdmin" Library="$webresource:Quote_main_library.js" Default="false" InvertResult="true" />
            </EnableRule>

//Javascript

function IsUserRoleAdmin()
{
         var currentUserRoles = Xrm.Page.context.getUserRoles();

         var isAdmin = false;
          for (var i = 0; i < currentUserRoles.length; i++)
          {
             var userRole = currentUserRoles[i];
            //check admin role 
                    //  if(userRole == "admin guid")
            // {
            //  isAdmin = true;
            // }
           }

 return isAdmin;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:17:09+00:00Added an answer on June 14, 2026 at 5:17 pm

    Yes you can hide or disable OOB buttons. This blog post provides some information.

    Your js code is incorrect as Xrm.Page.context.getUserRoles() returns an array of GUIDs not the role names so isAdmin will always be false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue trying to persist entities to the DB using code-first technique.
I have two issues I'm trying to work though. The first is I'm trying
I have an issue when trying to get Javascript to execute functions in my
I have this issue: first, I execute a SQL query using Java and then
I have couple of issues- the first constraint on select is loaded when reference
I have an issue in entity framework code first, three table in database as
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
First of all: I'm at Scala 2.8 I have a slight issue while using
I have a few weird issues I need to solve. First, let me show
I am creating my first (!) database, and I have run into an issue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.