Microsoft CRM 3.0 Experiences

Thursday, January 11, 2007

Using the MS CRM Onload event to retrieve online, live company information

Being able to edit the Onload event on a Microsoft CRM Account (or Contact, Opportunity, Lead for that matter) is fantastic. There is all sorts of clever stuff you can do. In this example I'll demonstrate how to retrieve live company data from an online Company Information site (MINT - https://mintuk.bvdep.com ) using a custom Companies House number field I created and IFRAME. The Onload event takes appends the Companies House number to a custom url and passes it to the IFRAME at load time and hey presto you get live, relevant company data in the IFRAME!

Companies House Field

The job I did was to create a Companies House field for the Account record by Customising the Account Entity.

To do this Go to Customization > Customize Entities > Accounts > Attributes and create a new Attribute called "Companies House No" (new_companieshouseno). And then add this field to the standard Account form. Under the Entity:Account click on "Forms and Views" and edit "Form" and use the tools to plop your new field onto the Form.


Adding an IFRAME


Fill the IFRAME properties as per shown in the picture leaving the URL as "about:blank" (we'll be filling in the correct url using the Onload event next!).

The Onload Event

To edit the Onload event you need to click on Form Properties, select Onload and click "Edit".
You can add your own javascript here to do all sorts of things and in this case I:
  1. Retrieved the value of the Companies House No field.
  2. Appended it to a MINT url.
  3. Passed the url to the IFRAME

The IFRAME then loads the MINT Company Information page when the Account opens and if a Company Number is not passed it defaults to a MINT search page.

The script I use is as follows:

var CRM_FORM_TYPE_UPDATE = 2;
// Only attempt to retrieve the MINT information on Update and when Online

if (IsOnline())

{

if (crmForm.FormType == CRM_FORM_TYPE_UPDATE)

{

// put the Companies House number into a variable

var CompanyNo=crmForm.all.new_companieshouseno.DataValue;

// append the variable to the MINT url, note the url contains xxxxxx for username and password, obviously i'm not going reveal my mint account details ;o)

var URL='https://mintuk.bvdep.com/Search.DirectCompanyName.serv?product=Mint&tpl=reportframe&stack=1&Kick=1&user=xxxxxx&pw=xxxxxx&&companyId=' + CompanyNo;

// pass the URL to the IFRAME

crmForm.all.IFRAME_Mint_Info.src=URL;

}}

And the result is as follows (note I have also a dedicated TAB for my MINT stuff):

0 Comments:

Post a Comment

<< Home