There are a number of good articles that walk through the technical process of adding a ribbon button that you can refer to. The following is a high level visual representation of adding a button that executes a custom action that should hopefully bring this all together succinctly. This article assumes you have read through some of the other literature that describes how you go about exporting, identifying, and editing the entity customization file that you wish to add a button to.
Please refer to the screenshot below.
The following are some of the more important sections of the edits that need to be made:
- CustomAction Id - Add an id here that uniquely identifies the custom action you are adding
- CustomAction Location - Identifies the ribbon to update. If you are updating an account, it will start with Mscrm.Form.account, if you are updating a lead it will start with Mscrm.Form.lead etc.
- CustomAction Sequence - Identifies where in the ribbon it will appear
- Button Id - Add an id here that uniquely identifies the button you are adding
- Button Command - Add a command name
- LabelText/Tooltips - Any descriptive text
- TemplateAlias - Defines how the button appears although I haven't delved very deep into this one yet. Default to "01".
- Images - Reference 16 and 32 icons that you should add as a web resource to your environment (optional)
- CommandDefinition Id - This should match the Button Command referenced in step #5.
- Command Definition Actions - This section defines the action to take when clicking the button. There are various actions that can be taken. The first example is commented and simply would take the user to a web page when clicked. The second example is a reference to a custom jscript function defined in the form jscript. I chose to reference the "default" contact library but this could be any jscript library.
- Function HelloWorld - The function in the second example above must be created in the relevant jscript library and should match the FunctionName from the CommandDefinition section
- Xrm.Page.ui.refreshRibbon - This is a command that you can optionally add to jscript. Some times after you click a ribbon button, you will want to disable that button or perhaps enable another button on the ribbon. By callling this command at the end of your jscript function, you instruct the ribbon to refresh and re-execute any of the Enable and Display rules to control the appearance of your button which I discuss in my next post.
That's it. Now when you click the ribbon button, you will receive a "Hello World" alert prompt.
That's a brief introduction to the topic. Refer to the CRM SDK for more configuration options.
No comments:
Post a Comment