Re: SOAP set_relationship with custom modules

Originally Posted by
davec2
Hello, I'm using the SOAP API with sugar professional 6.3.0, and am trying to run set_relationship between the Accounts module and a custom module. I've defined the relationship between the two modules (custom one-to-many accounts). However, when I try to call set_relationship via SOAP, the apache error log shows the following:
PHP Fatal error: Call to a member function add() on a non-object in /var/www/soap/SoapSugarUsers.php on line 1347
The offending block of sugar code is: (the line with->add())
if (!empty($key)) {
$mod->load_relationship($key);
$mod->$key->add($module2_id);
return $error->get_soap_array();
}
Upon further inspection, it turns out that the load_relationship() function call does in fact fail, however the failure is ignored in this code.
The data I'm passing in via the SOAP call is as follows:
Running set relationship with { 'module1': 'Accounts',
'module1_1d': '87183ff6-87b6-60a6-4d75-4e559394f422',
'module2': 'TR001_Releases',
'module2_id': 'a97346c3-bbb7-a3d5-f4f4-4e9778ce7a76'}
I've been trying to figure this out for a while now, but am starting to question if this is even possible... So, my question, is it even possible to use SOAP to relate an Account to a entity in a custom module?
Best Regards,
-Dave
Yes, you just need to use the link field name rather than the relationship name of 'TR001_Releases'. Check out this blog post for more details:
SugarCRM Developer Blog » Blog Archive » HOWTO: Dealing with set_relationship failures
John Mertic
Sugar Community Manager
Bookmarks