Hello, I need your help to solve a problem I'm having lately, about using Soap and the get_relationships and set_relationships calls.
The modules I need to get/write data from/to are Users, Accounts and SecurityGroups (an awesome module available in SugarForge).
SecurityGroups, in case you don't know sets many-to-many relationships between Users and Groups and between Accounts and Groups (to make it short).
Using Sugar SOAP, I can retrieve the Group (or more than one) a user is in, with this code:
I can also check which groups are related to an account, with this :PHP Code:$get_params2 = array('session'=>$session,
'module_name'=>'Users',
'module_id'=>'INSERT_USER_ID_HERE',
'related_module'=>'SecurityGroups',
'related_module_query'=>'',
'deleted'=>'false',
);
$result2 = $soapclient->call('get_relationships', $get_params2);
However, there is no way I can set the relationship between an Account and a Group. Those relationships are managed through a table that contains the fields ID (of the entry) and the IDs of the account and the group, respectively.PHP Code:$get_account_params = array('session'=>$session,
'module_name'=>'Accounts',
'module_id'=>'ACCOUNT_ID_HERE',
'related_module'=>'SecurityGroups',
'related_module_query'=>'',
'deleted'=>'false',
);
$account_result = $soapclient->call('get_relationships', $get_account_params);
I tried with the following code, without success:
PHP Code:$set_rel_params = array('session' => $session,
'set_relationship_value' => array(
'module1'=> 'Accounts',
'module1_id'=> '10160611-da35-6633-28b8-469e2b789c64',
'module2' => 'SecurityGroups',
'module2_id'=> '104123ab-7ae3-df7a-d45e-465bd921739e'));
$set_rel_result= $soapclient->call('set_relationships',$set_rel_params);
This does, in fact, create a new GROUP (!) and not a relation, in the table that contains the list of groups in SecurityGroup Module.
I tried all the combination of the 2 modules, I also searched the forums for more info, I edited the SoapSugarUsers.php file as suggested in many threads but I could not figure how to do what I need to do (setting the relationship between an Account and a Group) using Soap.
Any help would be appreciated.
Thank you in advance
Regards
Giovanni


LinkBack URL
About LinkBacks



Reply With Quote


Bookmarks