Skip to main content

August 04, 2010

Drupal, Salesforce, and Googlemaps Mashup....

Thought by FFW,

...Creates a Dynamic Sales Lead Generation Tool for Medical Laser Company.

FFW Agency Drupal Developers: Sciton Map

This mash-up powers an elegantly simple presentation for a patient making an inquiry about qualified physicians. We searched Sciton's Salesforce.com system for local physicians, then mapped office locations using Google Maps. This map shows results for north Atlanta, near Roswell, Georgia.

FFW Customizes Drupal Location Module with Maps of Distributors, Sales, & Physician Locations

Sciton(R) provides best-in-class laser and light source solutions for medical professionals in the aesthetic medical market. They came to FFW to rebuild their website in Drupal so that it would be very easy to manage. They also wanted FFW to create locater tools that would integrate with their Salesforce Customer Relationship Management (CRM) system. These locater tools would help prospective patients easily locate a qualified doctor nearby or allow physicians to find a distributor or direct sales office.

To meet these qualifications, We used Google Maps’ APIs, which created appealing and useful maps of the dealers, distributors, and physicians, plus allowed tabular information (contact information and website) to appear when the location bubble was clicked on. Salesforce.Com held all the location information, so We integrated that with Google Maps and the customized Drupal location module.

Patients Find Physicians; Physicians Find Sales Offices & Distributor Locations

Distributor Locator and Direct Sales Locator

Scion has a presence in more than 50 countries and distributors worldwide. To build the locators, we query the Salesforce.com database for distributors, then display them on a Google Map, highlighted by a bubble with the Sciton logo on it. Site visitors click on the bubbles and an address appears. We also created tabular contact information with a website contact form. We store the contact form information in Drupal, then push it to Salesforce.com. You can also export the info from Drupal via CSV for further analysis offline.

Physicians Locator

With the Sciton Physician Locator, prospective patients search for doctors by zip code or by city and state within a certain mileage radius. We created advanced search by treatment area (acnet, lyposuction, etc.) or Sciton product line also. These queries are stored in Salesforce.com as a sales lead, which can be further analyzed in Excel.

This type of locator site is very useful for companies with broad distribution channels, multiple locations, or wide geographic territories. Those already using Salesforce.com as their primary sales force automation (SFA) or CRM solution can pull addresses from the database to graphically display map location and other helpful information on a Drupal website. The following example shows you how to query a custom table from Salesforce.com for addresses and display them as pushpins on a Google Map.

Requirements

Before we start we need to prepare upfront some information from our Salesforce.com (SF) account:

  • username
  • password
  • security token (this can be obtained from your SF account by clicking Setup -> Reset security token and it should be a 24-char long string containing only alphanumeric characters).
  • WSDL (Web Service Description Language (WSDL): get it by clicking on "Generate Enterprise WSDL." To access the current WSDL for your organization, log in to your Salesforce.com organization and click Setup | Develop | API | Generate Enterprise WSDL. (let's name it enterprisesf.xml for this example, but you can name it anyway you want).

We'll start by creating a custom module under site/default/modules (Let's name it "custom")... custom.info and custom.module files.

Once the folder and the files were created unpack the SF PHP toolkit and place it under /sites/default/modules/custom/soapclient/ (image will be attached here with folder structure).

Copy the generated WSDL file under soapclient folder (so it will be located here /sites/default/modules/soapclient/enterpisesf.xml).

Once we have all this we can start writing our custom page, which will display all our distributors on a Google map.

<?php
require_once (drupal_get_path('module', 'custom').'/soapclient/SforceEnterpriseClient.php');

/**
 * Implementation of hook_menu().
 */
function custom_menu() {
  $items['distributors-list.html'] = array(
    'title' => 'Sales Force Query Results',
    'page callback' => 'custom_soap_connector',
    'page arguments' =>
    'access callback' => true,
  );
  return $items
}

function custom_soap_connector() {
  $our_google_map = array(
    'id' => 'example',
    'maptype' => 'Terrain',
    'width' => '400px',
    'height' => '400px',
    'latitude' => custom_get_latitude(arg(1)),
    'longitude' => custom_get_longitude(arg(1)),
    'zoom' => 12,
    'align' => 'left',
    'controltype' => 'Large',
    'mtc' => 'standard',
  );
 try {
  $mySforceConnection = new SforceEnterpriseClient();
  $USERNAME = 'username';
  $PASSWORD = 'passwordtoken';
  $mySoapClient = $mySforceConnection->createConnection(drupal_get_path('module', 'custom').'/soapclient/enterprise-sf.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $query = "SELECT  Name,ShippingCity, ShippingCountry, ShippingPostalCode, ShippingState, ShippingStreet from Account";
  $response = $mySforceConnection->query(($query));
  foreach ($response->records as $record) {
    $a = array();
    $a['text'] = $record->Name;
    $a['longitude'] = custom_get_longitude($record->ShippingPostalCode);
    $a['latitude'] = custom_get_latitude($record->ShippingPostalCode);
    $map_array2['markers'][] = $a;
   }
  } catch (Exception $e) {
  $output = $e->faultstring;
 } 

 $output .= theme('gmap', array('#settings' => $our_google_map));
 return $output;
}

function _get_simple_zip($zip_code) {
  $_temp = explode('-', $zip_code);
  return $_temp[0];
}

function custom_get_longitude($zip_code) {
  $zip_code = _get_simple_zip($zip_code);
  return _db_query("SELECT longitude FROM {zipcodes} WHERE zip='".$zip_code."'");
}

function custom_get_latitude($zip_code) {
  $zip_code = _get_simple_zip($zip_code);
  return   return _db_query("SELECT latitude FROM {zipcodes} WHERE zip='".$zip_code."'");
}
?>

If you are dealing with addresses vs. geo codes in your module, you can transform them to geo codes using the (gmap module and) google api. _gmap_str2coord or Google_Geocoder.

For this example we used the location module to position the pushpins on the map.

Tip - in case we are modifying the structure of SF object often by adding custom field (since we are modifying wsdl) a good behavior is to disable the cache. ini_set("soap.wsdl_cache_enabled", "0"); You can re-enable the cache once you are ready to launch.

ABOUT SCITON

Sciton provides best-in-class laser and light source solutions for medical professionals who want superior durability, performance, and value. Sciton offers superior medical devices for fractional and full-field skin resurfacing, superficial and deep skin peeling, hair removal, phototherapy, wrinkle reduction, laser-assisted lipolysis, scar reduction, acne treatment, varicose veins, and treatment of vascular and pigmented lesions. For more information and a complete listing of Sciton systems, please visit www.sciton.com