When creating a new custom activity entity you are presented with a great many checkboxes to choose from. One of these checkboxes will ensure that the activity type is included in the Activities Menu on records
The Custom Activities flyout menu is a dynamically generated menu so that if you load up an entity in the Ribbon Workbench and expand this button you won't see any menu items. This has been the subject for confusion for users who are trying to move this button out of the sub menu and put it on the main Command Bar as a short cut for uses. Since the menu is created dynamically at run time there is no button to customise and move. This post shows you how to create a custom activity button on the opportunity form.
1. Determine the Entity Type Code of your custom activity.
Each custom entity has an Entity Type code. This integer value is different to the entity logical name and could be different on each organization you deploy your solution. We need to know this entity type code in order to create a new record of a specific entity type.
To find the value, create a new record for your custom entity in Internet Explorer and press Ctrl-N (opens a new window with Url visible) and copy the URL. This should look something like:
You need to note the etc number for later.
2. Install Ribbon Workbench
You'll need to install the Ribbon Workbench as described by 'Getting started with the Ribbon Workbench'
3. Create and open a solution containing the Opportunity Entity
The Ribbon Workbench requires a solution to load that contains the entities that you wish to work on. Since we are adding the new button to the opportunity entity, add it to the solution – only add the entities you need to speed up the solution load/publish time. When you first open the Ribbon Workbench it will allow you to select your new solution.
4. Click on the 'Ribbon' tab and change drop down in the top right to 'Form'
We need a template command to use and so we select the 'Ribbon' view rather than the Command Bar view so to locate the 'Task' button on the Form ribbon.
5. Select the 'Add' tab and then right click on the 'Task' button and select 'Customise Command'
The Task button is located on the 'Add' tab. Using 'Customise Command' creates a copy of the add task command that we can change to reference our custom acitivty.
6. Expand the Commands node to see the customised command and select 'Mscrm.AddTaskToPrimaryRecord'.
7. Rename the command to be something like 'Mscrm.AddCustomActivityToPrimaryRecord'
By renaming the command we are creating a new command specifically for our new button, rather than customising the existing one.
Remember that the entity type code is unique to your custom entity – but it could change between deployments.
9. Right click on the command and select 'Edit Display Rules' and Remove the 'HideOnCommandBar' rule
Since the Task button only shows on the legacy ribbon, we need to change the command so it also shows on the command bar by removing this display rule.
10. Select the 'Command Bar' tab and drag a button onto the Form command bar
11. Set the Command to be your new custom command (e.g. Mscrm.AddCustomActivityToPrimaryRecord)
12. Set the image16 to be /_imgs/ribbon/AddActivity_16.png (or a custom image you have for your entity)
13. Expand the 'Display Rules' and set the 'IsCore' property to 'True' on each Display Rule.
14. Expand the 'Enable Rules' and set the 'IsCore' property to 'True' on each Enable Rule.
By setting the 'IsCore' property to true, we only reference them rather than redefining them.
15. Publish your customisations
16. Test the new button on the opportunity form!