2012-08-14 55 views
1

我使用SOAP API向SugarCRM添加新潛在客戶。此外,每當創建新的潛在顧客時,我都會使用插件來分配自動遞增的潛在顧客ID(http://www.sugarforge.org/projects/autoincrement/)。SugarCRM - 使用自動遞增的ID添加潛在客戶ID

現在,插件工作正常,如果我通過前端創建新的潛在客戶。但是,如果我使用SOAP API,則不會觸發將自動增量ID分配給潛在客戶的模塊中的功能。

我創建通過

$module = 'Leads'; 

    $params = array(
     'session'   => $session, 
     'module_name'  => $module, 
     'name_value_list' => array(
      array('name' => 'id',    'value' => ''), 
      //array('name' => 'int_lead_id_c', 'value' => ''),    
      array('name' => 'first_name',  'value' => $_POST["first_name"]), 
      array('name' => 'last_name',  'value' => $_POST["last_name"]), 
      array('name' => 'phone_home',  'value' => $_POST["phone"]), 
      array('name' => 'email1',   'value' => $_POST["email"]), 
      array('name' => 'assigned_user_id', 'value' => '1'), 
      ) 
     ); 

    //Create the Lead record 
    $lead_result = $soapclient->call('set_entry', $params); 

領先的模塊中的功能是這樣的一個:

class SugarFieldAutoincrement extends SugarFieldBase { 

    /** 
    * Override the SugarFieldBase::save() function to implement the logic to get the next autoincrement value 
    * and format the saved value based on the attributes defined for the field. 
    * 
    * @param SugarBean bean - the bean performing the save 
    * @param array params - an array of paramester relevant to the save, most likely will be $_REQUEST 
    * @param string field - the name of the field 
    */ 
    public function save(&$bean, $params, $field, $properties, $prefix = '') { 
    } 
} 

我如何才能確保,這一功能也被觸發,將通過SOAP引線時API?

非常感謝您的幫助! :-)

大衛

回答

1

您需要在字段的vardef記錄中將字段類型設置爲'autoincrement',將dbType設置爲'int'。

0

如果我沒有記錯的話,數據庫插入時的UUID()觸發對於大多數的表,所以你應該能夠完全刪除ID字段。

+0

我不認爲uuid是一個通用的sql函數,是嗎? – Anthony 2013-06-26 11:59:16

0

如果要在保存前觸發該功能,可以使用beforeSave邏輯掛鉤。