How to create a connection between pins and user modules in SugarCRM CE?

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); } 

This is the code I use to create relationships, according to most sugar lessons. The code works when I use 2 base modules (e.g. Leads / Contacts), but it fails when I try to use it with custom modules.

In this case, the geral_pessoa_juridica module is normal, geral is the package name and pessoa_juridica. I am sure that the name is correct, it works for other functions.

This function returns me this

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

I am not sure WHY this fails - when studying sugarcrm.log, I see that he did not even try to create a relationship.

I redo the module twice, try to create the tables manually, following the Sugar standard, which I saw in other respects, reset MySQL privileges, made all possible repairs in Sugar. I can not reinstall it because it is in production.

Any ideas on how to fix it?

+6
source share
2 answers

Solved or some.

  $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 } 
+1
source

Line 5 has an error:

 'module1' => 'geral_pessoa_juridica', 'module1_id', $pj_id, 

it should be:

 'module1' => 'geral_pessoa_juridica', 'module1_id' => $pj_id, 
+2
source

Source: https://habr.com/ru/post/890539/


All Articles