Modify OOB ribbon button for Specific Activity Type Entity

By | February 20, 2017

Introduction:

We recently had a business requirement where we wanted to hide the ‘Mark Complete’ OOB button from the home page of Activity entity. However, we wanted to hide this button for Service Activity entity and not for other activity types like Task, Appointment, Email, etc.

‘Mark Complete’ is a button on the Home Page of Activity entity that allows a user to complete the selected activity. This button is enabled when a user selects any Activity from the grid.

Note: The solution mentioned below will apply only for the view of specific entity i.e. Service Activity, Appointment, Task, etc. The solution is not applicable if the user selects the ‘All Activities’ view.

To hide ‘Mark Complete’ OOB button for Service Activity entity, follow the steps mentioned below;

1. Open Ribbon Workbench and select the solution, which contains the Activity entity.

2. By default, the Command property of the OOB ribbon button is disabled.

3. Therefore, first we need to customize the OOB ribbon button. To do this, right click on the ‘Mark Complete’ OOB ribbon button and select the ‘Customise Command’ option as seen below;

Customize OOB ribbon button
4. Now add ‘Enable Rules’ for ‘Mark Complete’ OOB ribbon button. In the ‘Enable Rules’, click on ‘Add Step’ and add ‘Custom Rule’.

5. Now type the function name and select the JavaScript library. Click on ‘Add Parameter’ and add CRM Parameter ‘SelectedEntityTypeName’ in the ‘Custom Rule’ as shown in the screenshot below;

Customize OOB ribbon button

6. To achieve the business requirement, we developed a JavaScript function mentioned below;

//hideMarkCompleteButton() function is used to show/hide the "Mark Complete" button on activity

function hideMarkCompleteButton(selectedentityName) {
    var functionName = "hideMarkCompleteButton() ";
    try {

        if (selectedentityName == "serviceappointment") {
            return false;
        } else {
            return true;
        }
    } catch (e) {
        alert(functionName + e.message);
    }

}

7. Add the above created rule into the command of ‘Mark Complete’ ribbon button as shown in the screenshot below;

Customize OOB ribbon button

8. Publish the solution.

Conclusion:

Using Enable Rules, it is possible to override the default behaviour and show/hide property of ribbon buttons.

Before you move on to the next post, Have a look at Click2Clone – Copy Dynamics CRM/365 Records in 1 Click!

2 thoughts on “Modify OOB ribbon button for Specific Activity Type Entity

  1. MANISH JAIN

    Hi ,
    Thanks for wonderful post. Is it possible to hide / disable the Close Activity Button upon completion of custom activity in timeline control in UCI .

    Thanks

    Reply
    1. inogic Post author

      Hi,

      We cannot hide the “Close Activity” button in the timeline control in UCI using supported way.

      Hope this helps.

      Thanks!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *