Reputation: 36
On a fresh install of sugarcrm 6.5 CE, I created a custom module "Groupes", with a many-to-many relationship to Accounts.
I added a record in Accounts, and one in "Groupes", and linked them together.
My goal is to use REST v4 to retrieve records in "Groupes", and the related Account records.
Using get_entry_list, I tried the following :
//retrieve records ----------------------------------------
$get_entry_list_parameters = array(
//session id
'session' => $session_id,
//The name of the module from which to retrieve records
'module_name' => "Accounts",
//The SQL WHERE clause without the word "where".
'query' => "",
//The SQL ORDER BY clause without the phrase "order by".
'order_by' => "",
//The record offset from which to start.
'offset' => "0",
//Optional. The list of fields to be returned in the results
'select_fields' => array(
'id',
'name',
),
//A list of link names and the fields to be returned for each link name
'link_name_to_fields_array' => array(
array(
'name' => 'offi1_groupes',
'value' => array(
'id',
'name',
),
),
),
//The maximum number of results to return.
'max_results' => '10000',
//To exclude deleted records
'deleted' => 0,
//If only records marked as favorites should be returned.
'Favorites' => false,
);
$get_entry_list_result = call("get_entry_list", $get_entry_list_parameters, $url);
Below you can see what I get : as you can see, the "Groupes" record are not fetched. Any clue on what went wrong ?
stdClass Object
(
[result_count] => 1
[total_count] => 1
[next_offset] => 1
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => 671d043b-7c39-e2b8-66ee-5249d0d8c954
[module_name] => Accounts
[name_value_list] => stdClass Object
(
[id] => stdClass Object
(
[name] => id
[value] => 671d043b-7c39-e2b8-66ee-5249d0d8c954
)
[name] => stdClass Object
(
[name] => name
[value] => Pharmacie témoin
)
)
)
)
[relationship_list] => Array
(
[0] => stdClass Object
(
[link_list] => Array
(
[0] => stdClass Object
(
[name] => offi1_groupes
[records] => Array
(
)
)
)
)
)
)
Upvotes: 1
Views: 3157
Reputation: 11
First Get Account ID
self::$soap->get_entry_list(self::$sessionId, 'Accounts', "name='NAME'");
$acc_id = $response->entry_list[0]->id;
Get Groups ID From Relations
$get_relationships_result = self::$soap->get_relationships(self::$sessionId,"Accounts",$acc_id,"Groupes");
$groups_id = $get_relationships_result->ids[0]->id;
back and get Related Groups Information
self::$soap->get_entry_list(self::$sessionId, 'Groupes', "Groupes.id=$groupes_id");
Upvotes: 1