【问题标题】:SugarCRM - Add leads with auto-incremented IDSugarCRM - 添加具有自动递增 ID 的潜在客户
【发布时间】:2012-08-21 20:10:02
【问题描述】:

我使用 SOAP API 向 SugarCRM 添加新的潜在客户。此外,每当创建新潜在客户时,我都会使用一个插件来分配一个自动递增的潜在客户 ID (http://www.sugarforge.org/projects/autoincrement/)。

现在,如果我通过前端创建新的潜在客户,插件可以正常工作。但是,如果我使用 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 添加潜在客户时也触发了此功能?

非常感谢您的帮助! :-)

大卫

【问题讨论】:

    标签: api soap sugarcrm


    【解决方案1】:

    您需要在字段的 vardef 记录中将字段类型设置为“autoincrement”,并将 dbType 设置为“int”。

    【讨论】:

      【解决方案2】:

      如果我没记错的话,对于大多数表,数据库在插入时都有一个 UUID() 触发器,因此您应该能够完全删除 id 字段。

      【讨论】:

        【解决方案3】:

        如果要在保存前触发函数,可以使用 beforeSave 逻辑钩子。

        【讨论】:

          猜你喜欢
          • 2012-12-23
          • 2020-09-01
          • 1970-01-01
          • 1970-01-01
          • 2017-08-29
          • 2022-11-15
          • 1970-01-01
          • 2014-11-02
          • 2018-12-14
          相关资源
          最近更新 更多