1

在全新安装的 sugarcrm 6.5 CE 上,我创建了一个自定义模块“Groupes”,与 Accounts 具有多对多关系。

我在 Accounts 中添加了一条记录,在“Groupes”中添加了一条记录,并将它们链接在一起。

我的目标是使用 REST v4 检索“Groupes”中的记录以及相关的 Account 记录。

使用 get_entry_list,我尝试了以下操作:

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

您可以在下面看到我得到的内容:如您所见,未获取“Groupes”记录。关于出了什么问题的任何线索?

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
                                    (
                                    )

                            )

                    )

            )

    )

)

图片

4

1 回答 1

1

首先获取账户ID

self::$soap->get_entry_list(self::$sessionId, 'Accounts', "name='NAME'");
$acc_id = $response->entry_list[0]->id;

从关系中获取组 ID

$get_relationships_result = self::$soap->get_relationships(self::$sessionId,"Accounts",$acc_id,"Groupes");
$groups_id = $get_relationships_result->ids[0]->id;

返回并获取相关组信息

self::$soap->get_entry_list(self::$sessionId, 'Groupes', "Groupes.id=$groupes_id");
于 2013-12-18T15:00:33.287 回答