1. Export the solution and open the customization.xml file using visual studio to edit.
2. Now edit the customization file, change the <RibbonDiffXml> of contact entity like this
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="sample.SubGrid.contact.MainTab.CustomGroup.CustomAction" Location="Mscrm.SubGrid.contact.MainTab.Groups._children" Sequence="110">
<CommandUIDefinition>
<Group Id="sample.SubGrid.contact.MainTab.CustomGroup.SampleGroup" Command="sample.SubGrid.contact.MainTab.CustomGroup.Command" Title="$LocLabels:CustomGroup.Title" Sequence="32" Template="Mscrm.Templates.Flexible2" Image32by32Popup="$webresource:new_samplebutton32x32.png">
<Controls Id="sample.SubGrid.contact.MainTab.CustomGroup.Controls">
<Button Id="sample.SubGrid.contact.MainTab.CustomGroup.CustomButton.A" Command="sample.SubGrid.contact.MainTab.CustomGroup.CustomButton.A.Command" Sequence="21" LabelText="$LocLabels:CustomButton.A.LableText" ToolTipTitle="$LocLabels:CustomButton.A.LableText" ToolTipDescription="$LocLabels:CustomButton.A.ToolTipDescription" Image16by16="$webresource:new_samplebutton16x16.png" Image32by32="$webresource:new_samplebutton32x32.png" TemplateAlias="o1" />
</Controls>
</Group>
</CommandUIDefinition>
</CustomAction>
<CustomAction Id="sample.SubGrid.contact.MainTab.CustomGroup.Maxsize.CustomAction" Location="Mscrm.SubGrid.contact.MainTab.Scaling._children" Sequence="120">
<CommandUIDefinition>
<MaxSize Id="sample.SubGrid.contact.MainTab.CustomGroup.Maxsize" GroupId="sample.SubGrid.contact.MainTab.CustomGroup.SampleGroup" Sequence="21" Size="LargeMedium" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="sample.SubGrid.contact.MainTab.CustomGroup.Command">
<EnableRules>
<EnableRule Id="sample.SubGrid.contact.CustomGroup.EnableRule" />
</EnableRules>
<DisplayRules>
</DisplayRules>
<Actions />
</CommandDefinition>
<CommandDefinition Id="sample.SubGrid.contact.MainTab.CustomGroup.CustomButton.A.Command">
<EnableRules>
<EnableRule Id="sample.SubGrid.contact.SingleRecordSelection.EnableRule" />
</EnableRules>
<DisplayRules />
<Actions>
<!-- This new_sample.js webresource must be added before customizing -->
<JavaScriptFunction FunctionName="TestFunction" Library="$webresource:new_sample.js">
<CrmParameter Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules>
<EnableRule Id="sample.SubGrid.contact.CustomGroup.EnableRule">
<EntityRule AppliesTo="PrimaryEntity" EntityName="account" />
</EnableRule>
<EnableRule Id="sample.SubGrid.contact.SingleRecordSelection.EnableRule">
<SelectionCountRule AppliesTo="SelectedEntity" Minimum="1" Maximum="1" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels>
<LocLabel Id="CustomButton.A.LableText">
<Titles>
<Title languagecode="1033" description="Sample Button" />
</Titles>
</LocLabel>
<LocLabel Id="CustomButton.A.ToolTipDescription">
<Titles>
<Title languagecode="1033" description="Sample Button Description" />
</Titles>
</LocLabel>
<LocLabel Id="CustomGroup.Title">
<Titles>
<Title languagecode="1033" description="Custom Group" />
</Titles>
</LocLabel>
</LocLabels>
</RibbonDiffXml>
3. java script function on custom button click
function TestFunction(selectedRecordID) {
alert(selectedRecordID[0]);
// your logic
}
4. Save the customization.xml file and export back to CRM.
Now you will find the custom group and button on the contact subgrid. Here custom button will be enable when you are accessing contact entity subgrid from only Account entity. For rest of all the entities this custom button will be in disable mode. Only single record selection from subgrid will be allowed.
keep coding!!!!!
Thanks a lot!. The Custom action location was a trouble for me. Works like a charm
ReplyDeleteHi,
ReplyDeleteI am using CRM 2013, i need to copy a field values to subgrid.
how can i do this. please anyone help me if you have any information.
Thanks in advance,
Nagaraju