locked
CRM 2011- Hide Deactivate Button RRS feed

  • Question

  • Hi,

    I want to hide "Deactivate" button for all entities on CRM 2011 for all Security Roles except System Administrator. I have modified my Application Ribbon file to do this. I have put up a misc. privilege of "BulkDelete" to display that button to System Administrator. But even System Administrator is not able to see "Deactivate" button. Is there something wrong with below XML of Application ribbon.

     

     

    <ImportExportXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <Entities></Entities>

      <Roles></Roles>

      <Workflows></Workflows>

      <FieldSecurityProfiles></FieldSecurityProfiles>

      <Templates />

      <RibbonDiffXml>

        <CustomActions>

         <HideCustomAction HideActionId="ABC.Mscrm.Form.All.Deactivate" Location="Mscrm.Form.{!EntityLogicalName}.Deactivate"/>

         <HideCustomAction HideActionId="ABC.Mscrm.HomepageGrid.All.Deactivate" Location="Mscrm.HomepageGrid.{!EntityLogicalName}.Deactivate"/>

         <HideCustomAction HideActionId="ABC.Mscrm.SubGrid.All.Deactivate" Location="Mscrm.SubGrid.{!EntityLogicalName}.Deactivate"/>

        </CustomActions>

        <CommandDefinitions>

          <CommandDefinition Id="Mscrm.HomepageGrid.Deactivate">

            <EnableRules>

              <EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />

              <EnableRule Id="Mscrm.SelectionCountAtLeastOne" />

            </EnableRules>

            <DisplayRules>

              <DisplayRule Id="ABC.Mscrm.BulkDelete" />

              <DisplayRule Id="Mscrm.CanWriteSelected" />

              <DisplayRule Id="Mscrm.SelectedEntityHasStatecode" />    

            </DisplayRules>

            <Actions>

              <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.deactivate" Library="/_static/_common/scripts/RibbonActions.js">

                <CrmParameter Value="SelectedControl" />

                <CrmParameter Value="SelectedControlSelectedItemReferences" />

                <CrmParameter Value="SelectedEntityTypeCode" />

              </JavaScriptFunction>

            </Actions>

          </CommandDefinition>

     

          <CommandDefinition Id="Mscrm.Form.Deactivate">

            <EnableRules>

              <EnableRule Id="Mscrm.CanWritePrimary" />

            </EnableRules>

            <DisplayRules>

              <DisplayRule Id="ABC.Mscrm.BulkDelete" />

              <DisplayRule Id="Mscrm.CanWritePrimary" />

              <DisplayRule Id="Mscrm.PrimaryIsActive" />

              <DisplayRule Id="Mscrm.PrimaryEntityHasStatecode" />

              <DisplayRule Id="Mscrm.PrimaryIsNotActivity" />

     

            </DisplayRules>

            <Actions>

              <JavaScriptFunction FunctionName="changeState" Library="/_static/_forms/form.js">

                <StringParameter Value="deactivate" />

                <CrmParameter Value="PrimaryEntityTypeCode" />

                <StringParameter Value="5" />

              </JavaScriptFunction>

            </Actions>

          </CommandDefinition>

        </CommandDefinitions>

        <RuleDefinitions>

          <TabDisplayRules />

          <DisplayRules>

            <DisplayRule Id="ABC.Mscrm.BulkDelete">

              <MiscellaneousPrivilegeRule Default="false" PrivilegeDepth="Global" PrivilegeName="BulkDelete" />

            </DisplayRule>

          </DisplayRules>

          <EnableRules />

        </RuleDefinitions>

        <LocLabels />

      </RibbonDiffXml>

      <EntityMaps />

      <EntityRelationships />

      <OrganizationSettings />

      <optionsets />

      <Languages>

        <Language>1033</Language>

      </Languages>

    </ImportExportXml>

     

    Tuesday, October 25, 2011 3:29 PM

Answers

All replies

  • That is fne, but I do not want to use Java Script. I want to handle this by privilege.
    Tuesday, October 25, 2011 6:50 PM
  • Unfortunately there isn't granular enough control using permissions alone to allow for this unless you remove all write privileges from the user.  You can control this though in jscript in combination with a ribbon rule.  I do not believe there is another way to tackle this in a supported manner.
    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Tuesday, October 25, 2011 6:57 PM
    Moderator
  • I know that but I have done this for one entity using <CustomAction> and <DisplayRule>. I want this to be more easily using <HideCustomAction> and<DisplayRule>. May be <HideCustomAction> simply hides without looking into <MiscellaneousPrivilegeRule >  or <DisplayRule>.
    Tuesday, October 25, 2011 7:24 PM
    • Marked as answer by myCRMGuy Friday, October 28, 2011 7:22 PM
    Tuesday, October 25, 2011 7:32 PM
    Moderator
  • I got it worked with <CustomAction>. See below XML.

    <RibbonDiffXml>

        <CustomActions>

          <CustomAction Id="ABC.Mscrm.Form.entity.MainTab.Save.Controls" Location="Mscrm.Form.{!EntityLogicalName}.MainTab.Save.Controls._children">

            <CommandUIDefinition>

              <Button Id="Mscrm.Form.{!EntityLogicalName}.Deactivate" ToolTipTitle="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" ToolTipDescription="$Resources(EntityPluralDisplayName):Ribbon.Tooltip.Deactivate" Command="Mscrm.Form.Deactivate" Sequence="60" Alt="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" LabelText="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" Image16by16="/_imgs/ribbon/deactivate16.png" Image32by32="/_imgs/ribbon/Deactivate_32.png" TemplateAlias="o2" />

            </CommandUIDefinition>

            </CustomAction>

          <CustomAction Id="ABC.Mscrm.HomepageGrid.entity.MainTab.Management.Controls" Location="Mscrm.HomepageGrid.{!EntityLogicalName}.MainTab.Management.Controls._children">

            <CommandUIDefinition>

              <Button Id="Mscrm.HomepageGrid.{!EntityLogicalName}.Deactivate" ToolTipTitle="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" ToolTipDescription="$Resources(EntityPluralDisplayName):Ribbon.Tooltip.Deactivate" Command="Mscrm.HomepageGrid.Deactivate" Sequence="40" Alt="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" LabelText="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" Image16by16="/_imgs/ribbon/deactivate16.png" Image32by32="/_imgs/ribbon/Deactivate_32.png" TemplateAlias="o2" />

            </CommandUIDefinition>

          </CustomAction>

          <CustomAction Id="ABC.Mscrm.SubGrid.entity.MainTab.Management.Controls" Location="Mscrm.SubGrid.{!EntityLogicalName}.MainTab.Management.Controls._children">

            <CommandUIDefinition>

              <Button Id="Mscrm.SubGrid.{!EntityLogicalName}.Deactivate" ToolTipTitle="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" ToolTipDescription="$Resources(EntityPluralDisplayName):Ribbon.Tooltip.Deactivate" Command="Mscrm.HomepageGrid.Deactivate" Sequence="70" Alt="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" LabelText="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" Image16by16="/_imgs/ribbon/deactivate16.png" Image32by32="/_imgs/ribbon/Deactivate_32.png" TemplateAlias="o2" />

            </CommandUIDefinition>

          </CustomAction>

         </CustomActions>

        <CommandDefinitions>

          <CommandDefinition Id="Mscrm.HomepageGrid.Deactivate">

            <EnableRules>

              <EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />

              <EnableRule Id="Mscrm.SelectionCountAtLeastOne" />

            </EnableRules>

            <DisplayRules>

              <DisplayRule Id="ABC.Mscrm.BulkDelete" />

              <DisplayRule Id="Mscrm.CanWriteSelected" />

              <DisplayRule Id="Mscrm.SelectedEntityHasStatecode" />    

            </DisplayRules>

            <Actions>

              <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.deactivate" Library="/_static/_common/scripts/RibbonActions.js">

                <CrmParameter Value="SelectedControl" />

                <CrmParameter Value="SelectedControlSelectedItemReferences" />

                <CrmParameter Value="SelectedEntityTypeCode" />

              </JavaScriptFunction>

            </Actions>

          </CommandDefinition>

     

          <CommandDefinition Id="Mscrm.Form.Deactivate">

            <EnableRules>

              <EnableRule Id="Mscrm.CanWritePrimary" />

            </EnableRules>

            <DisplayRules>

              <DisplayRule Id="ABC.Mscrm.BulkDelete" />

              <DisplayRule Id="Mscrm.CanWritePrimary" />

              <DisplayRule Id="Mscrm.PrimaryIsActive" />

              <DisplayRule Id="Mscrm.PrimaryEntityHasStatecode" />

              <DisplayRule Id="Mscrm.PrimaryIsNotActivity" />

     

            </DisplayRules>

            <Actions>

              <JavaScriptFunction FunctionName="changeState" Library="/_static/_forms/form.js">

                <StringParameter Value="deactivate" />

                <CrmParameter Value="PrimaryEntityTypeCode" />

                <StringParameter Value="5" />

              </JavaScriptFunction>

            </Actions>

          </CommandDefinition>

        </CommandDefinitions>

        <RuleDefinitions>

          <TabDisplayRules />

          <DisplayRules>

            <DisplayRule Id="ABC.Mscrm.BulkDelete">

              <MiscellaneousPrivilegeRule Default="true" PrivilegeDepth="Global" PrivilegeName="BulkDelete" />

            </DisplayRule>

          </DisplayRules>

          <EnableRules />

        </RuleDefinitions>

        <LocLabels />

      </RibbonDiffXml>

    Tuesday, October 25, 2011 8:32 PM
  • I am glad the ribbon diff override worked for you.

    Have a nice day!


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Friday, October 28, 2011 7:40 PM
    Moderator
  • Hi Friend,

    I have situation where i have to Show/Hide the system button "Deactivate" from Accounts entity's Ribbon from Home Grid and Form both. I created a custom entity and privilege "no permission" to "delete" for those Roles.

    Part of the Accounts Customisation.xml looks like this (Only the ribbon part)

    <RibbonDiffXml>
            <CustomActions />
            <Templates>
              <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
            </Templates>
            <CommandDefinitions>
        <CommandDefinition Id="Mscrm.HomepageGrid.account.Deactivate">
          <EnableRules>
            <EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />
            <EnableRule Id="Mscrm.SelectionCountAtLeastOne" />
          </EnableRules>
          <DisplayRules>
            <DisplayRule Id="Mscrm.CanWriteSelected" />
            <DisplayRule Id="Mscrm.SelectedEntityHasStatecode" />
            <DisplayRule Id="new.contact.inrole.DisplayRule" />
          </DisplayRules>
          <Actions>
            <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.deactivate" Library="/_static/_common/scripts/RibbonActions.js">
              <CrmParameter Value="SelectedControl" />
              <CrmParameter Value="SelectedControlSelectedItemReferences" />
              <CrmParameter Value="SelectedEntityTypeCode" />
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
        <CommandDefinition Id="Mscrm.Form.account.Deactivate">
          <EnableRules>
            <EnableRule Id="Mscrm.CanWritePrimary" />
          </EnableRules>
          <DisplayRules>
            <DisplayRule Id="Mscrm.CanWritePrimary" />
            <DisplayRule Id="Mscrm.PrimaryIsActive" />
            <DisplayRule Id="Mscrm.PrimaryEntityHasStatecode" />
            <DisplayRule Id="Mscrm.PrimaryIsNotActivity" />
            <DisplayRule Id="new.contact.inrole.DisplayRule" />
          </DisplayRules>
          <Actions>
            <JavaScriptFunction FunctionName="changeState" Library="/_static/_forms/form.js">
              <StringParameter Value="deactivate" />
              <CrmParameter Value="PrimaryEntityTypeCode" />
              <StringParameter Value="5" />
            </JavaScriptFunction>
          </Actions>
        </CommandDefinition>
      </CommandDefinitions>
      <RuleDefinitions>
        <TabDisplayRules />
        <DisplayRules>
          <DisplayRule Id="Mscrm.CanWriteSelected">
            <EntityPrivilegeRule PrivilegeType="Write" PrivilegeDepth="Basic" AppliesTo="SelectedEntity" />
          </DisplayRule>
          <DisplayRule Id="Mscrm.SelectedEntityHasStatecode">
            <EntityPropertyRule AppliesTo="SelectedEntity" PropertyName="HasStateCode" PropertyValue="true" />
          </DisplayRule>
          <DisplayRule Id="Mscrm.CanWritePrimary">
            <EntityPrivilegeRule PrivilegeType="Write" PrivilegeDepth="Basic" AppliesTo="PrimaryEntity" />
          </DisplayRule>
          <DisplayRule Id="Mscrm.PrimaryIsActive">
            <FormStateRule State="Existing" />
          </DisplayRule>
          <DisplayRule Id="Mscrm.PrimaryEntityHasStatecode">
            <EntityPropertyRule AppliesTo="PrimaryEntity" PropertyName="HasStateCode" PropertyValue="true" />
          </DisplayRule>
          <DisplayRule Id="Mscrm.PrimaryIsNotActivity">
            <EntityPropertyRule AppliesTo="PrimaryEntity" PropertyName="IsActivity" PropertyValue="false" />
          </DisplayRule>
          <DisplayRule Id="new.contact.inrole.DisplayRule">
            <EntityPrivilegeRule EntityName="new_securitylink" PrivilegeType="Delete" PrivilegeDepth="Global" />        
          </DisplayRule>
        </DisplayRules>
        <EnableRules>
          <EnableRule Id="Mscrm.VisualizationPaneNotMaximized">
            <CustomRule FunctionName="Mscrm.RibbonActions.disableButtonsWhenChartMaximized" Library="/_static/_common/scripts/RibbonActions.js">
              <CrmParameter Value="SelectedControl" />
            </CustomRule>
          </EnableRule>
          <EnableRule Id="Mscrm.SelectionCountAtLeastOne">
            <SelectionCountRule AppliesTo="SelectedEntity" Minimum="1" />
          </EnableRule>
          <EnableRule Id="Mscrm.CanWritePrimary">
            <RecordPrivilegeRule PrivilegeType="Write" AppliesTo="PrimaryEntity" />
          </EnableRule>
        </EnableRules>
      </RuleDefinitions>
            <LocLabels />
          </RibbonDiffXml>

    I have not defined any Custom Actions and Tab Display Rules. What is am missing here. This piece of code is not working.

    Can you help me out please.



    Puneet Joshi

    Tuesday, February 28, 2012 8:17 PM
  • Probebly this might a very late reply. The below code worked for me. Few observations, hope it will help the new developers. 

     - I had to give <EnableRules/>,<Actions/> eventhough there are no code inside to bypass the error during Import solution.
     - When I gave my entity name inside  <EntityPrivilegeRule , it did not work, so changed to AppliesTo="SelectedEntity"

     <CommandDefinitions>
          <CommandDefinition Id="Mscrm.HomepageGrid.Deactivate">
            <EnableRules/>          
            <DisplayRules>          
              <DisplayRule Id="Atlas.DisplayRule" />          
            </DisplayRules>
            <Actions/>          
          </CommandDefinition>      
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules>         
            <DisplayRule Id="Atlas.DisplayRule">
              <EntityPrivilegeRule AppliesTo="SelectedEntity" PrivilegeType="Create" PrivilegeDepth="Basic" />
            </DisplayRule>
          </DisplayRules>
          <EnableRules/>        
        </RuleDefinitions>

    RN


    Monday, October 15, 2012 9:53 PM