[Drupal] How to pass value of a field related to a field in another module in sugar CRM?

| | 2 min read

Customer relationship management is a model for managing a company’s interactions with customers. Sugar CRM is one of the largest open source CRM available. Drupal can be integrated with Sugar CRM using SugaronDrupal module. Read on to know how to pass the value of a field related to a field in another module in Sugar CRM while working with Drupal.

Drupal can be integrated with Sugar CRM using SugaronDrupal module.

For passing values of related fields to sugar CRM "set_relationship" SOAP request can be used.

For passing values to Sugar CRM for a field related to a field in another module following function can be used.

/**
 * Implements  set_relationship sugarcrm webservice
 */
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;
}

For example if you want to set relationship between Accounts and contact module then create "One to Many relationship" in Accounts module with the "Contacts" module in studio configuration of Sugar CRM(Example of relationship created - 'accounts_contacts_1'). Refer the following code to pass values of related field using custom code.

$account_contacts_relationship = sugarondrupal_set_relationship(array(
  'module_name' => 'Accounts',
  'module_id' => $account_name_entry['id'],
  'link_field_name' => 'accounts_contacts_1',
  'related_ids' => array($contact_entry['id']),
  'delete' => 0,
 ));

In the above example module_id is the session id for "Accounts" module which is obtained from the sugarondrupal_get_entry_list() and the related_ids contains session id of "Contacts" module obtained from sugarondrupal_get_entry_list(). 'link_field_name' is the name of the relationship which is set in the Accounts module.

Hope this helps.