[Drupal] Learn how to integrate SugarCRM with Drupal - 2

| | 2 min read

Sugar CRM is a web application used for customer relationship management. Checkout our article on How to integrate Drupal with SugarCRM.Now, let's see how to push the data from Drupal to SugarCRM

How to set an entry on sugarCRM

Use the function sugarondrupal_set_entry() to set entry to sugar CRM endpoint. In the following example, User is the name of the module and test is the package key. Also, in the array name_value_list, add all the fields where you want to set data in sugarCRM endpoint.

$customer_entry = sugarondrupal_set_entry(
  'module_name' => 'test_User',
  'name_value_list' => array(
     array('name' => 'Name', 'value' => $name),
     array('name' => 'uid', 'value' => $user_id),
     array('name' => 'mail', 'value' => $mail),

How to get an entry on sugarCRM

  $result = sugarondrupal_get_entry_list(
     'module_name' => 'test_User',
     'query' => "uid = $user_id",
     'offset' => 0,
     'deleted' => 0,
     'max_results' => 10,

This code snippet will return an array with result count and id of the entry in sugar CRM and name_value_list - 'list of all fields of the module', and the relationship if there is any.

If you get status report as ok, then you are good to go. You can add custom code to push data from drupal to sugarCRM using the module sugarondrupal. Please checkout How to integrate SugarCRM and Drupal for more information.

How to set relationship between two entries

// Custom function written to set relationship.
function sugarondrupal_set_relationship($params) {
 // we provide the session element of the params
 $params = array_merge(array('session' => sugarondrupal_session_get()), $params);
 $result = sugarondrupal_sugarcrm_service_request('set_relationship', $params);
 return $result;

// Set relationship between the Order and User.
$relation_result = sugarondrupal_set_relationship(
   'module_name' => 'test_Order',
   'module_id' => $order_entry['id'],
   'link_field_name' => 'adz_order_adz_user',
   'related_ids' => array($customer_entry['id']),

This will return an array and if the relationship is set as ok, it will return the value '1' for the key 'created'.