Home > MS CRM 4.0 > Adding CRM style button

Adding CRM style button


This Javascript function converts a text field into a CRM style button.

crmForm.createVirtualButton = function(idField) {
    var tmpid = idField.id;

    idField.outerHTML = "<table cellspacing="0" cellpadding="0" class="ms-crm-ActionBar" style="BORDER-BOTTOM: #6893cf 1px solid;">" +
    "<tr><td class="ms-crm-MenuBar-Items"><LI tabIndex="-1" class="ms-crm-Menu" title="Save and Close" action="crmForm.SaveAndClose();" onclick="window.execScript(action)" id="_MBcrmFormSaveAndClosejj">" +
    "<SPAN class="ms-crm-Menu-Label"><A onclick="return false;" href="javascript:onclick();" target="_self" tabIndex="-1" class="ms-crm-Menu-Label">" +
    "<IMG src="/_imgs/ico/16_saveClose.gif" alt="Save and Close" tabIndex="-1" class="ms-crm-Menu-ButtonFirst">" +
    "<SPAN tabIndex="0" class="ms-crm-MenuItem-TextRTL">Save and Close</SPAN></A></SPAN></LI></td></tr></table>";
}

Call the function: 

crmForm.createVirtualButton(crmForm.all.new_savebutton);

new_savebutton is a nvarchar field. the Javascript function convert it to a CRM style "Save and Close" button. This function can be modified to a more generic function, so you can pass in the button text, image, and onclick event etc. However, we do not often create multiple buttons on one form, and…I am too lazy to do that. Try it yourself if you want and have fun!

Advertisements
Categories: MS CRM 4.0
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: