MS CRM Add a button/link to open new browser window from form

If you want to place a button on a CRM form without using the isv.config file you can do so by javascript. This examples will take a dummy attribute field and make it look and act as a button by calling a javascript function with the onclick event. Place the code below in the onLoad event of your CRM form. In this example the name och city fields are passed as search arguments to an external website.

//make a field look and act like a button
crmForm.all.stockexchange.style.textAlign = “center”;
crmForm.all.stockexchange.vAlign = “middle”;
crmForm.all.stockexchange.style.cursor = “hand”;
crmForm.all.stockexchange.style.backgroundColor = “#CADFFC”;
crmForm.all.stockexchange.style.color = “#000000″;
crmForm.all.stockexchange.style.borderColor = “#330066″;
crmForm.all.stockexchange.style.fontWeight = “bold”;

crmForm.all.stockexchange.DataValue = “Sök bolag”;
crmForm.all.stockexchange.attachEvent(“onclick”, SearchAllaBolag);


function SearchAllaBolag()
{

  //Get values from form
  if (crmForm.all.name.DataValue != null)
  {
    var what = escape(crmForm.all.name.DataValue);   
    var url = ‘
http://www.allabolag.se/?what=’ + what

    if (crmForm.all.address1_city.DataValue != null)
    {
      var where  = escape(crmForm.all.address1_city.DataValue);
      url += ‘&where=’ + where;
    }

    //open browser window
    //alert(url);
    window.open(url);
  }
  else
  {
    alert(Name is missing.’);
  }
}

Credits to http://crmstuff.blogspot.com/2008/02/create-button-on-your-form.html

About these ads

Leave a Reply

Please log in using one of these methods to post your comment:

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