我使用SOAP API向SugarCRM添加新的销售线索。此外,每当创建新的销售线索时,我都会使用一个插件来分配一个自动递增的销售线索ID (http://www.sugarforge.org/projects/autoincrement/)。
现在,如果我通过前端创建一个新的lead,这个插件工作得很好。但是,如果我使用SOAP API,则模块中将自动递增ID分配给lead的函数不会触发。
我通过以下方式创建销售线索
$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添加销售线索时,如何确保此函数也被触发?
非常感谢你的帮助!:-)
大卫
发布于 2012-08-16 03:52:39
您需要在字段的vardef记录中将字段类型设置为'autoincrement‘,并将dbType设置为'int’。
发布于 2012-08-15 03:51:42
如果我没记错的话,对于大多数表,数据库在insert时都有一个UUID()触发器,所以您应该能够完全删除id字段。
发布于 2012-08-21 20:10:03
如果您想在保存前触发函数,可以使用beforeSave逻辑钩子。
https://stackoverflow.com/questions/11953969
复制相似问题