Answered by:
Adding custom JavaScript to an Out Of Box Ribbon Button

Question
-
Hi Guys,
I am trying to add a JavaScript function to the out of the box ribbon button 'Add Existing". Below is what i currently have, this does not seem to be getting the job done. Any ideas as to what I may be doing wrong?
<RibbonDiffXml> <CustomActions> <HideCustomAction Location="Mscrm.Form.EntityName.SaveAndNew" HideActionId="Mscrm.Form.EntityName.SaveAndNew.HideAction" /> <HideCustomAction Location="Mscrm.SubGrid.EntityName.AddNewStandard" HideActionId="Mscrm.SubGrid.EntityName.AddNewStandard.HideAction" /> <HideCustomAction Location="Mscrm.SubGrid.EntityName.Edit" HideActionId="Mscrm.SubGrid.EntityName.Edit.HideAction" /> <HideCustomAction Location="Mscrm.SubGrid.EntityName.NewRecord" HideActionId="Mscrm.SubGrid.EntityName.NewRecord.HideAction" /> <CustomAction Id="Mscrm.SubGrid.EntityName.AddExistingAssoc_CustomAction" Location="Mscrm.SubGrid.EntityName.AddExistingAssoc" Sequence="40"> <CommandUIDefinition> <Button Id="Mscrm.SubGrid.EntityName.AddExistingAssoc" Command="Mscrm.AddExistingRecordFromSubGridAssociated_CustomAction" Sequence="40" LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.AddExisting" Alt="$Resources(EntityDisplayName):Ribbon.SubGrid.AddExisting" Image16by16="/_imgs/ribbon/AddExistingStandard_16.png" Image32by32="/_imgs/ribbon/AddExistingStandard_32.png" TemplateAlias="o1" ToolTipTitle="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddExistingAssoc_ToolTipTitle" ToolTipDescription="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddExistingAssoc_ToolTipDescription"/> </CommandUIDefinition> </CustomAction> </CustomActions> <Templates> <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates> </Templates> <CommandDefinitions> <CommandDefinition Id="Mscrm.AddExistingRecordFromSubGridAssociated_CustomAction"> <EnableRules> <EnableRule Id="Mscrm.AddExistingRecordFromSubGridAssociated_CustomRule" /> <EnableRule Id="Mscrm.AppendToPrimary" /> <EnableRule Id="Mscrm.EntityFormIsEnabled" /> </EnableRules> <DisplayRules> <DisplayRule Id="Mscrm.AddExisting" /> <DisplayRule Id="Mscrm.ShowForManyToManyGrids" /> <DisplayRule Id="Mscrm.AppendToPrimary" /> <DisplayRule Id="Mscrm.AppendSelected" /> </DisplayRules> <Actions /> </CommandDefinition> </CommandDefinitions> <RuleDefinitions> <TabDisplayRules /> <DisplayRules /> <EnableRules> <EnableRule Id="Mscrm.AddExistingRecordFromSubGridAssociated_CustomRule"> <CustomRule FunctionName="myFunction" Library="$webresource:MyFile" Default="false" /> </EnableRule> </EnableRules> </RuleDefinitions> <LocLabels /> </RibbonDiffXml>
Thanks
Wednesday, June 4, 2014 12:14 PM
Answers
-
Hi,
I would recommend using the Ribbon workbench to modify the ribbon and wire up the JavaScript. http://www.develop1.net/public/Download%20Ribbon%20Workbench%202013.aspx
- Marked as answer by _Hopeful Tuesday, May 9, 2017 7:30 AM
Wednesday, June 4, 2014 12:55 PM
All replies
-
Hi,
I would recommend using the Ribbon workbench to modify the ribbon and wire up the JavaScript. http://www.develop1.net/public/Download%20Ribbon%20Workbench%202013.aspx
- Marked as answer by _Hopeful Tuesday, May 9, 2017 7:30 AM
Wednesday, June 4, 2014 12:55 PM -
Is it hitting your custom script at all?
I would put a debug line (simply 'debugger;' without the quotes around it) as the first line of the script and run it through. This will show you if the script is being run, and you can check whether it is performing as expected as well :)
Wednesday, June 4, 2014 1:58 PM -
Not even hitting my script. Any further ideas?Wednesday, June 4, 2014 3:11 PM