Saturday, February 4, 2012

Add Custom Button, Custom Group and Custom Tab in Custom Entity or system Entity

Here you can find the complete code to add Custom Button, Custom Group and Custom Tab in Custom Entity.

Steps:
1 Export the entity
2 Edit the customizations.xml in Visual Studio editor
3 Copy the below code and replace it with RibbonDiffXml
4 Import and Publish the Solution
5 Test and Verify the Requirements
6 Note: If you required to open intelisense in customizations.xml then
1 go in XML menu in VS
2 click on Schema
3 Click on Add
4 select the path \sdk\schemas of CRM 2011
5 Select Customizationssolution.xsd, ribboncore.xsd, ribbontypes.xsd and ribbonwss.xsd files
6 Click open
7 Now check Intelisense

<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Sample.Form.new_test.CustomTab.CustomAction" Location="Mscrm.Tabs._children" Sequence="40">
<CommandUIDefinition>
<Tab Id="Sample.Form.new_test.CustomTab" Command="Sample.Form.new_test.CustomTab" Title="My First Custom Tab" Description="Finally managed to put my first custom tab" Sequence="40">
<Scaling Id="Sample.Form.new_test.CustomTab.Scaling">
<MaxSize Id="Sample.Form.new_test.CustomTab.FirstGroup.MaxSize" GroupId="Sample.Form.new_test.CustomTab.FirstGroup" Sequence="10" Size="LargeMedium" />
</Scaling>
<Groups Id="Sample.Form.new_test.CustomTab.Groups">
<Group Id="Sample.Form.new_test.CustomTab.FirstGroup" Command="Sample.Form.new_test.FirstGroup" Sequence="10" Title="Custom Group" Template="Mscrm.Templates.3.3">
<Controls Id="Sample.Grid.new_test.CustomTab.FirstGroup.Controls">
<Button Id="Sample.Form.new_test.CustomTab.FirstGroup.FirstButton" ToolTipTitle="My First Button Tool Tip" ToolTipDescription="My First Button Tool Tip Description" Command="Sample.Form.new_test.FirstButton" Sequence="10" LabelText="First Button" Alt="Alt First Button" TemplateAlias="o1" />
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
</CustomAction>
<CustomAction Id="Sample.new_test.form.Save.CustomAction" Location="Mscrm.Form.new_test.MainTab.Save.Controls._children" Sequence="80">
<CommandUIDefinition>
<Button Id="Sample.new_test.form.Save.Button" Command="Sample.new_test.form.Save.Command" LabelText="Button" ToolTipTitle="Button ToolTip" ToolTipDescription="Button Description" TemplateAlias="o1" Image16by16="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" />
</CommandUIDefinition>
</CustomAction>
<CustomAction Id="Mscrm.Form.new_test.CustomGroup.CustomAction" Location="Mscrm.Form.new_test.MainTab.Groups._children" Sequence="81">
<CommandUIDefinition>
<Group Id="Mscrm.Form.new_test.CustomGroup.Group" Command="Mscrm.Form.new_test.CustomGroup.Command" Title="HKG Group" Sequence="11" Template="Mscrm.Templates.3.3">
<Controls Id="Mscrm.Form.new_test.CustomGroup.Controls">
<Button Id="Mscrm.Form.new_test.CustomGroup.Button.HK" Sequence="10" Command="Mscrm.Form.new_test.CustomGroup.Button.HK.Command" LabelText="HK" ToolTipTitle="Button ToolTip(HK)" ToolTipDescription="Button Description(HK)" TemplateAlias="o1" Image16by16="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" />
</Controls>
</Group>
</CommandUIDefinition>
</CustomAction>
<CustomAction Id="Mscrm.Form.new_test.CustomGroup.MaxSize.CustomAction"
Location="Mscrm.Form.new_test.MainTab.Scaling._children"
Sequence="120">
<CommandUIDefinition>
<MaxSize Id="Mscrm.Form.new_test.CustomGroup.MaxSize"
GroupId="Mscrm.Form.new_test.CustomGroup.Group"
Sequence="21"
Size="LargeLarge" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Sample.Form.new_test.CustomTab">
<EnableRules>
<EnableRule Id="Mscrm.Enabled " />
</EnableRules>
<DisplayRules></DisplayRules>
<Actions />
</CommandDefinition>
<CommandDefinition Id="Sample.Form.new_test.FirstButton">
<EnableRules>
<EnableRule Id="Mscrm.Enabled " />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Sample.new_test.form.FormStateNotNew.DisplayRule"></DisplayRule>
</DisplayRules>
<Actions></Actions>
</CommandDefinition>
<CommandDefinition Id="Sample.Form.new_test.FirstGroup">
<EnableRules>
<EnableRule Id="Mscrm.Enabled " />
</EnableRules>
<DisplayRules></DisplayRules>
<Actions />
</CommandDefinition>
<CommandDefinition Id="Sample.new_test.form.Save.Command">
<EnableRules />
<DisplayRules />
<Actions>
<JavaScriptFunction Library="$webresource:new_JS_Common_Library" FunctionName="show">
<StringParameter Value="A" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
<CommandDefinition Id="Mscrm.Form.new_test.CustomGroup.Button.HK.Command">
<EnableRules />
<DisplayRules />
<Actions>
<Url Address="http://www.google.com" />
</Actions>
</CommandDefinition>
<CommandDefinition Id="Mscrm.Form.new_test.CustomGroup.Command">
<EnableRules>
<EnableRule Id="Mscrm.NotOffline"/>
</EnableRules>
<DisplayRules>
<DisplayRule Id="Mscrm.NotOffline"/>
</DisplayRules>
<Actions />
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules>
<TabDisplayRule TabCommand="Sample.Form.new_test.CustomTab">
<EntityRule EntityName="new_test" Context="Form" AppliesTo="PrimaryEntity" />
</TabDisplayRule>
</TabDisplayRules>
<DisplayRules>
<DisplayRule Id="Sample.new_test.form.FormStateNotNew.DisplayRule">
<FormStateRule State="Create" InvertResult="true" />
</DisplayRule>
</DisplayRules>
<EnableRules />
</RuleDefinitions>
<LocLabels>
<LocLabel Id="Sample.new_test.form.Save.LabelText">
<Titles>
<Title languagecode="1033" description="Custom Button1" />
</Titles>
</LocLabel>
<LocLabel Id="Sample.new_test.form.Save.ToolTip">
<Titles>
<Title languagecode="1033" description="Custom Button1" />
</Titles>
</LocLabel>
</LocLabels>
</RibbonDiffXml>

No comments: