Tuesday 16 July 2013

Add web-resource (HTML control like button, check box etc.) in CRM Form

Example of add button in CRM Form like







1. Double click on your section like below image.

    Set the following things.

    Set web resource image.
    Name of button (web resource).
    Label of button (web resource).



2. Create java-script function call on Form load

function CompetitorLoad() {
convertWebResourceToButton('WebResource_btnCalculate', 'Calculate Implants', '150px', '0px', function () { window.location.reload(true); return false; });

}

 
function convertWebResourceToButton(fldName, btnLabel, btnWidth, leftMargin, evt) {
var btn = '<button id="btn_' + fldName + '" ' +
' style="margin-left:' + leftMargin + ';width:' + btnWidth + ';" ' +
' class="ms-crm-Button" ' +
' onmouseover="Mscrm.ButtonUtils.hoverOn(this);" ' +
' onmouseout="Mscrm.ButtonUtils.hoverOff(this);" '
+ '>' + btnLabel + '</button>';
var ctrl = Xrm.Page.ui.controls.get(fldName)._control.get_element().childNodes[1];
 
 
ctrl.innerHTML = btn;
 
$(ctrl.firstChild).bind('click', evt);
 
}

 Set function to page load like


 

No comments:

Post a Comment