Hi,

Here are the steps to add new Tab, Group and Buttons to the ‘Contact’ form and call .jscript functions on button click.

Ribbon Customizations - Contact Form
Ribbon Customizations – Contact Form

Steps :-

  • Create a new .jscript file “contact.js” with below functions

function fnA() {

alert(“Button \”A\” clicked!!!”);

}

function fnB() {

alert(“Button \”B\” clicked!!!”);

}

  • Open CRM application and add the “contact.js” as web resource
  • Create a new unmanaged solution and add “Contact” entity and “contact.js” web resource
  • Export the solution to the local folder
  • Unzip the folder
  • Open “customizations.xml” in Visual studio
  • Navigate to “<Entities><Entity>Contact”
  • Go to  <RibbonDiffXml> node and replace with below XML

 

<RibbonDiffXml>

<CustomActions>

<CustomAction Id=”Sample.Form.contact.CustomTab.CustomAction” Location=”Mscrm.Tabs._children” Sequence=”40″>

<CommandUIDefinition>

<Tab Id=”Sample.Form.contact.CustomTab” Command=”Sample.Form.contact.CustomTab”

Title=”$LocLabels:Sample.contact.CustomTab.Title”

Description=”$LocLabels:Sample.contact.CustomTab.Description” Sequence=”40″>

<Scaling Id=”Sample.Form.contact.CustomTab.Scaling”>

<MaxSize Id=”Sample.Form.contact.CustomTab.CustomGroup.MaxSize”

GroupId=”Sample.Form.contact.CustomTab.CustomGroup” Sequence=”10″ Size=”LargeMedium” />

</Scaling>

<Groups Id=”Sample.Form.contact.CustomTab.Groups”>

<Group Id=”Sample.Form.contact.CustomTab.CustomGroup”

Command=”Sample.Form.contact.CustomGroup”

Sequence=”10″ Title=”$LocLabels:Sample.contact.CustomTab.CustomGroup.Title” Template=”Mscrm.Templates.3.3″>

<Controls Id=”Sample.Form.contact.CustomTab.CustomGroup.Controls”>

<Button Id=”Sample.Form.contact.CustomTab.CustomGroup.ButtonA”

ToolTipTitle=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonA.LabelText”

ToolTipDescription=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonA.ToolTipDescription”

Command=”Sample.Form.contact.ButtonA” Sequence=”10″

LabelText=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonA.LabelText”

Alt=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonA.LabelText”

Image16by16=”/_imgs/ribbon/runreport16.png” Image32by32=”/_imgs/ribbon/runreport32.png” TemplateAlias=”o1″ />

<Button Id=”Sample.Form.contact.CustomTab.CustomGroup.ButtonB”

ToolTipTitle=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonB.LabelText”

ToolTipDescription=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonB.ToolTipDescription”

Command=”Sample.Form.contact.ButtonB” Sequence=”20″

LabelText=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonB.LabelText”

Alt=”$LocLabels:Sample.contact.CustomTab.CustomGroup.ButtonB.LabelText”

Image16by16=”/_imgs/ribbon/runreport16.png” Image32by32=”/_imgs/ribbon/runreport32.png” TemplateAlias=”o1″ />

</Controls>

</Group>

</Groups>

</Tab>

</CommandUIDefinition>

</CustomAction>

</CustomActions>

<Templates>

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

</Templates>

<CommandDefinitions>

<CommandDefinition Id=”Sample.Form.contact.CustomGroup”>

<EnableRules>

<EnableRule Id=”Mscrm.Enabled” />

</EnableRules>

<DisplayRules />

<Actions />

</CommandDefinition>

<CommandDefinition Id=”Sample.Form.contact.ButtonA”>

<EnableRules>

<EnableRule Id=”Mscrm.Enabled” />

</EnableRules>

<DisplayRules />

<Actions>

<JavaScriptFunction Library=”$webresource:new_contact” FunctionName=”fnA”></JavaScriptFunction>

</Actions>

</CommandDefinition>

<CommandDefinition Id=”Sample.Form.contact.ButtonB”>

<EnableRules>

<EnableRule Id=”Mscrm.Enabled” />

</EnableRules>

<DisplayRules />

<Actions>

<JavaScriptFunction Library=”$webresource:new_contact” FunctionName=”fnB”></JavaScriptFunction>

</Actions>

</CommandDefinition>

</CommandDefinitions>

<RuleDefinitions>

<TabDisplayRules>

<TabDisplayRule TabCommand=”Sample.Form.contact.CustomTab”>

<EntityRule EntityName=”contact” Context=”Form” AppliesTo=”PrimaryEntity” />

</TabDisplayRule>

</TabDisplayRules>

<DisplayRules />

<EnableRules>

</EnableRules>

</RuleDefinitions>

<LocLabels>

<LocLabel Id=”Sample.contact.CustomTab.Title”>

<Titles>

<Title languagecode=”1033″ description=”My Tab” />

</Titles>

</LocLabel>

<LocLabel Id=”Sample.contact.CustomTab.Description”>

<Titles>

<Title languagecode=”1033″ description=”My Tab” />

</Titles>

</LocLabel>

<LocLabel Id=”Sample.contact.CustomTab.CustomGroup.Title”>

<Titles>

<Title languagecode=”1033″ description=”My Group” />

</Titles>

</LocLabel>

<LocLabel Id=”Sample.contact.CustomTab.CustomGroup.ButtonA.LabelText”>

<Titles>

<Title languagecode=”1033″ description=”A” />

</Titles>

</LocLabel>

<LocLabel Id=”Sample.contact.CustomTab.CustomGroup.ButtonA.ToolTipDescription”>

<Titles>

<Title languagecode=”1033″ description=”Button A” />

</Titles>

</LocLabel>

<LocLabel Id=”Sample.contact.CustomTab.CustomGroup.ButtonB.LabelText”>

<Titles>

<Title languagecode=”1033″ description=”B” />

</Titles>

</LocLabel>

<LocLabel Id=”Sample.contact.CustomTab.CustomGroup.ButtonB.ToolTipDescription”>

<Titles>

<Title languagecode=”1033″ description=”Button B” />

</Titles>

</LocLabel>

</LocLabels>

</RibbonDiffXml>

You can download the complete solution from this location

Download Solution

Hope it helps 🙂

Advertisements
Advertisements

3 responses to “Adding New Tab & Group & Buttons to CRM form Ribbon”

  1. Opening a report using ribbon button in CRM 2011 « Rajeev Pentyala – Dynamics CRM Blog Avatar

    […] Call openReport(“My Account Report”) function from ribbon button (How to call function from ribbon button) […]

  2. Mahesh Avatar
    Mahesh

    Hi Rajeev,

    In Crm 4.0, under Opportunity entity, we have a custom button “New Wizard” in the Menu bar. On click of this button opens a Silverlight application using which we create a new opprtunity record.

    Now I want to do the same in CRM 2011 environment.Under which section I am supposed to give the Url details (As we give in ISV file).
    It will very helpful if you put some words on this.

    1. Rajeev Pentyala Avatar

      Hi Mahesh,
      Please confirm either u want this in sitemap or ribbon.

      If its ribbon,u can put a new ribbon button either in existing Tab/Group or New Tab/Group.

      On Button “CommandDefinition” define a Jscript function and open the silver light window.

      If u want in sitemap,export sitemap client extension and edit it (Same as CRM 4.0)

      Thanks,
      Rajeev

Leave a comment