Adding a new ribbon button (Qualify Lead)

This is a continuation of a previous post, where we removed the Qualify button from the Lead entity. This time we will be adding our own custom button.

Start by digging through the SDK. If you don’t have it, get it from HERE.

At the following path we’ll find the definitions for all the ootb entities:

sdk\resources\exportedribbonxml

look for the one related to Leads (leadribbon.xml).

In the <Ribbon> element you will the definitions for Tabs > Tab. We are looking for the Form’s main tab

<Tab Id=”Mscrm.Form.lead.MainTab” …

Identify the group you want to place your new button into, and copy the control ID for one of the other controls in that group. In my case, I want to place the new Qualify button in the Actions group.

Mscrm.Form.lead.MainTab.Actions.Controls

with this piece of info on hand, let’s go to the solution that includes the Lead entity, and add the two images we need for the button. These are two .png images, one 16×16, the other 32×32. Also, if you don’t have a JavaScript resource added, add it now. You will be able to call a JS function with this button.

Export the solution, and unzip it. Open up customizations.xml and look for the Lead entity section. In the <CustomActions></CustomActions>, where we added the HideCustomAction elements in the previous post, add right underneath those two the following code:

<CustomAction Id="Nav.lead.Form.QualifyLead.CustomAction"
            Location="Mscrm.Form.lead.MainTab.Actions.Controls._children"
            Sequence="1" >          
            <CommandUIDefinition>
                <Button Id="Nav.lead.Form.QualifyLead.Button"
                    Command="Nav.lead.Form.QualifyLead.Command"
                    LabelText="Qualify"
                    ToolTipTitle="Qualify the Lead"
                    ToolTipDescription="Qualify the current Lead"
                    TemplateAlias="o1"
                    Image16by16="$webresource:nav_btn_qualify16"
                    Image32by32="$webresource:nav_btn_qualify32"/>
            </CommandUIDefinition>
          </CustomAction>

Also, replace <CommandDefinitions /> with the following:

<CommandDefinitions>
            <CommandDefinition Id="Nav.lead.Form.QualifyLead.Command">
                <EnableRules>
                </EnableRules>
                <DisplayRules>
                </DisplayRules>
                <Actions>
                   
<JavaScriptFunction Library="$webresource:Nav_JS_Common_Lib"
                        FunctionName="launchWorkflow"
                        />
                </Actions>
            </CommandDefinition>
        </CommandDefinitions>

Do observe that the two images we’ve loaded for the button are in fact:

  • nav_btn_qualify16
  • nav_btn_qualify_32

and the JS resource is Nav_JS_Common_Lib. The function we are calling is launchWorkflow and for the purpose of testing we can add the following function in our resource library:

function launchWorkflow()
{
alert("From within launchWorkflow JS function!");
}

That’s it, now re-package the solution, and load it back. Test it by going to a Lead, and clicking the new Qualify ribbon button.

image

You will get the following pop-up:

image

Enjoy!

One thought on “Adding a new ribbon button (Qualify Lead)

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: