如何在SugarCRM CE中创建Leads和Custom Modules之间的关系?

Luc*_*lli 6 php soap web-services relationship sugarcrm

function createPJOpportunityRelationship($pj_id, $op_id) {
    echo "creating relationship";

    $set_relationship_value = array(
        'module1' => 'geral_pessoa_juridica', 'module1_id' => $pj_id,
        'module2' => 'Opportunities', 'module2_id' => $op_id
    );

    $set_relationship_params = array(
        'session' => $this->ses,
        'set_relationship_value' => $set_relationship_value
    );

    $set_relationship_result = $this->soap->call('set_relationship', array(
        'session' => $this->ses,
        'set_relationship_value' => $set_relationship_value));

    var_dump($set_relationship_result);
}
Run Code Online (Sandbox Code Playgroud)

根据大多数糖教程,这是我用来创建关系的代码.当我使用2个基本模块(如Leads/Contacts)时,代码可以正常工作,但是当我使用自定义构建的模块尝试它时它会失败.

在这种情况下,geral_pessoa_juridica模块是自定义模块,geral是包,pessoa_juridica是名称.我确定名称是正确的,它适用于其他功能.

这个函数给我回复了

5ec9ca75-e09d-e2d8-0c2b-4df7ac377dcf creating relationship array(3) { ["created"]=> int(0) ["failed"]=> int(1) ["deleted"]=> int(0) }

我不确定它为什么会失败 - 研究sugarcrm.log,我发现它甚至没有试图建立这种关系.

我重新模拟了两次模块,尝试按照我在其他关系中看到的Sugar标准手动创建表,刷新MySQL权限,在Sugar中进行所有修复.我无法重新安装它,因为它正在生产中.

关于如何修复它的任何想法?

Luc*_*lli 1

解决了,或者有点。

    $set_relationship_params = array(
        'session' => $this->ses,
        'module_name' => 'custom_module', /* custom module, where the relationship was created, "primary module" */
        'module_id' => $custom_id, /* id of site, get from set_entry call */
        'link_field_name' => 'module', /* the LINK field type name, from Step 5  */
        'related_ids' => array($module_id) /* id of Account you want to relate to */
    );

    print_r($result = $this->soap->call('set_relationship',$set_relationship_params)); //nuSoap
}
Run Code Online (Sandbox Code Playgroud)