Have you gotten a requirement to override a system ribbon or command button? If yes then this article will help you to implement your requirement.
Requirement: Let's say we have a requirement to prompt the user before saving the record and we need to save or cancel the save operation.
Solution: We can create a custom button to replicate the out-of-the-box button, we will be calling the same method that is called from the out-of-the-box button. Once our button is ready we will hide the out-of-the-box button. To implement our requirement use the following procedure.
Note: You can follow our previous article to get the RibbonWorkBench solution, to create the demo solution and add existing entities. We will override the Save button on the account entity.
- Name: OnSave.js
- Display Name: OnSave.js
- Type: Script (Jscript)
- function OverrideSave()
- {
- //We will be changing it in later step
- }
Now we will create a custom button and will copy the properties or save button. Using the following procedure:
- Open RibbonWorkBench and select our Demo solution
- Drag a Button from the Toolbox and leave it next to the Save button under the Form section
- Right-click on the system Save button and select Customize Command
- Copy all properties system Save button to our custom button except the Sequence and CommandCore properties (we need to copy and paste these properties one by one)

Now we need to check the command associated with the system save button and need to see which function and parameter is used for that. Use the following procedure.
- Right-click on Command and select Add New, we need to add a command for your custom Save button.
- Click on Actions lookup then click on Add and select JavaScript Function Action
- Write our function name and select our web resource
- Click on Parameters lookup then click on Add and select Crm Parameter
- Select Primary Control under the Value drop down

- Select our custom Save button and select our command name under the command drop down
- Right-click on the system Save button and select the Hide Button option
- Click on the Publish button to publish your changes
- Open our JavaScript web resource and change the function definition as in the following
- function OverrideSave()
- {//Capture response
- var response=confirm("Do want to save ??");
- if(response==true){
- //system function
- Mscrm.RibbonActions.saveForm();
- } }

Vithal WadjePosted Apr 9, 2015, 2:20 PM
nice keep it up
Santhakumar MunuswamyPosted Apr 9, 2015, 2:20 PM
Good