Thanks for all these posts... I finally was successful building a relationship between Accounts and my custom module Sites via SOAP. Sugar CE 5.5.4 and nusoap latest.
An Account can have many sites. A site belongs to one Account.
1. In module builder, create (basic) module Sites and add a new relationship. Primary Module: Site, Rel: Many to One, Secondary Module: Accounts. Add this Accounts relationship to your Sites list view if you want.
2. Deploy the module. Use Admin->Repair and run Quick Repair and Rebuild, then run Rebuild Relationships.
3. Use your new module and create data via the Sugar UI to make sure it works as expected (Subpanel under Accounts called "Sites", etc.)
4. Use soap to call get_available_modules to figure out the name of your custom module as far as the SOAP API is concerned
5. Use soap to call get_module_fields with the name of your module from step 4. Look through the results at the link_fields array, and find your link type field for your relationship.
For me this looked like:
Code:
[3] => Array
(
[name] => a9582_sites_accounts
[type] => link
[relationship] => a9582_sites_accounts
[module] =>
[bean_name] =>
) 6. Make your normal soap set_entry call. Forget about setting the relationship in this call (the easy way, like setting account_id field when inserting a contact, which somehow automagically populates the relationship, will not work).
7. Make a second soap call to method set_relationship. You must have the order correct for this call. For me, the call looks like:
Code:
$set_relationship_params = array(
'session' => $session,
'module_name' => 'a9582_sites', /* custom module, where the relationship was created, "primary module" */
'module_id' => $sugarID, /* id of site, get from set_entry call */
'link_field_name' => 'a9582_sites_accounts', /* the LINK field type name, from Step 5 */
'related_ids' => array($myAccountSugarID) /* id of Account you want to relate to */
);
$result = $client->call('set_relationship',$set_relationship_params); //nuSoap The only weird part is that there seem to be additional link fields for my custom module (like a9582_sites_accounts_1). I ignored these are used the most sensible and first one. These may be from hours of failed attempts.
Bookmarks