locked
Create a custom rule to hide button on form ribbon in crm 2011 RRS feed

  • Question

  • Hi,

    I have created a custom button on ribbon of a custom entity. But i want to specify a customrule for the button. I have done the following but not able to import. 

    <RibbonDiffXml>
            <CustomActions>
          <CustomAction Id="CI_formlevelAccept" Location="Mscrm.Form.new_copf.MainTab.ExportData.Controls._children" Sequence="76">
        <CommandUIDefinition>
        <Button Id="B_formbuttonAccept" Command="Cmd_JavaScript1" LabelText="Accept" ToolTipTitle="Accept COPF" ToolTipDescription="Form Level Button"
        TemplateAlias="o1"/>
        </CommandUIDefinition>
                </CustomAction>
               </CustomActions> 

    <Templates>
              <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
            </Templates>
            <CommandDefinitions>
       <CommandDefinition Id="Cmd_JavaScript1">
        <EnableRules>
         <EnableRule Id="Mscrm.CustomcheckRole"></EnableRule>
        </EnableRules>
        <DisplayRules></DisplayRules>
        <Actions>
        <JavaScriptFunction Library="$webresource:new_copf_acceptreject_buttonclick" FunctionName="Accept"></JavaScriptFunction>
        </Actions>
       </CommandDefinition>
       
       <EnableRules>
        <EnableRule Id="Mscrm.CustomcheckRole">
         <CustomRule FunctioName="callMain" Library="$webresource:new_commonlibrary"></CustomRule>
        </EnableRule>
       </EnableRules>

    </CommandDefinitions>
            <RuleDefinitions>
              <TabDisplayRules />
              <DisplayRules />
              <EnableRules />
            </RuleDefinitions>
            <LocLabels />
          </RibbonDiffXml>

    Please anyone verify my code and let me know about the mistakes.

    Regards,

    Kishan. 

    Tuesday, September 13, 2011 12:55 PM

Answers

  • The schema is not right and mis spell FumctionName in custom rule

    Here is correct file.

    <RibbonDiffXml>

    <CustomActions>

    <CustomAction Id="CI_formlevelAccept" Location="Mscrm.Form.new_copf.MainTab.ExportData.Controls._children" Sequence="76">

    <CommandUIDefinition>

    <Button Id="B_formbuttonAccept" Command="Cmd_JavaScript1" LabelText="Accept" ToolTipTitle="Accept COPF" ToolTipDescription="Form Level Button"

    TemplateAlias="o1"/>

    </CommandUIDefinition>

    </CustomAction>

    </CustomActions>

    <Templates>

    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>

    </Templates>

    <CommandDefinitions>

    <CommandDefinition Id="Cmd_JavaScript1">

    <EnableRules>

    <EnableRule Id="Mscrm.CustomcheckRole"></EnableRule>

    </EnableRules>

    <DisplayRules></DisplayRules>

    <Actions>

    <JavaScriptFunction Library="$webresource:new_copf_acceptreject_buttonclick" FunctionName="Accept"></JavaScriptFunction>

    </Actions>

    </CommandDefinition>

     

    </CommandDefinitions>

    <RuleDefinitions>

    <TabDisplayRules />

    <DisplayRules />

    <EnableRules>

    <EnableRule Id="Mscrm.CustomcheckRole">

    <CustomRule FunctionName="callMain" Library="$webresource:new_commonlibrary"></CustomRule>

    </EnableRule>

    </EnableRules>

    </RuleDefinitions>

    <LocLabels />

    </RibbonDiffXml>

     I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Tuesday, September 13, 2011 1:16 PM
    • Marked as answer by Donna EdwardsMVP Wednesday, September 14, 2011 1:58 PM
    Tuesday, September 13, 2011 1:15 PM

All replies

  • The schema is not right and mis spell FumctionName in custom rule

    Here is correct file.

    <RibbonDiffXml>

    <CustomActions>

    <CustomAction Id="CI_formlevelAccept" Location="Mscrm.Form.new_copf.MainTab.ExportData.Controls._children" Sequence="76">

    <CommandUIDefinition>

    <Button Id="B_formbuttonAccept" Command="Cmd_JavaScript1" LabelText="Accept" ToolTipTitle="Accept COPF" ToolTipDescription="Form Level Button"

    TemplateAlias="o1"/>

    </CommandUIDefinition>

    </CustomAction>

    </CustomActions>

    <Templates>

    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>

    </Templates>

    <CommandDefinitions>

    <CommandDefinition Id="Cmd_JavaScript1">

    <EnableRules>

    <EnableRule Id="Mscrm.CustomcheckRole"></EnableRule>

    </EnableRules>

    <DisplayRules></DisplayRules>

    <Actions>

    <JavaScriptFunction Library="$webresource:new_copf_acceptreject_buttonclick" FunctionName="Accept"></JavaScriptFunction>

    </Actions>

    </CommandDefinition>

     

    </CommandDefinitions>

    <RuleDefinitions>

    <TabDisplayRules />

    <DisplayRules />

    <EnableRules>

    <EnableRule Id="Mscrm.CustomcheckRole">

    <CustomRule FunctionName="callMain" Library="$webresource:new_commonlibrary"></CustomRule>

    </EnableRule>

    </EnableRules>

    </RuleDefinitions>

    <LocLabels />

    </RibbonDiffXml>

     I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Tuesday, September 13, 2011 1:16 PM
    • Marked as answer by Donna EdwardsMVP Wednesday, September 14, 2011 1:58 PM
    Tuesday, September 13, 2011 1:15 PM
  • Hi,

    I Used the above code given by you. I imported it and while checking for the function mentioned callMain it is not calling the function.

    Thursday, September 15, 2011 7:04 AM
  • I wrote a alert message in the function callMain, but it is not firing.
    Thursday, September 15, 2011 7:07 AM
  • debug your javascript webresource if the crm is calling the webresource.

    In your webresource, add

    debugger;

    as a first line.

    http://crmbusiness.wordpress.com/2011/02/18/crm-2011-how-to-debug-javascript-with-ie8/

    I hope this helps.


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Thursday, September 15, 2011 11:11 AM
    Thursday, September 15, 2011 11:11 AM