SuiteCRM如何检索所有与帐户相关的联系人

时间:2015-06-08 08:53:51

标签: php api rest sugarcrm suitecrm

我在使用REST API v4_1检索所有与帐户相关的联系人时遇到问题。我正在使用SuiteCRM。

正如我可以通过表结构看到的,有表帐户和accounts_contacts,其中包含联系人的ID。我使用此代码获取与已登录用户相关的所有帐户。

$get_entry_parameters = array
        (
            //session id
            'session' => $this->session_id,

            //The name of the module from which to retrieve records
            'module_name' => "Accounts",

            //The ID of the record to retrieve.
            //'id' => NULL,

            //Where conditions without "where" keyword
            'query' => "accounts.assigned_user_id='" . $this->user_id . "'",

            //Sort result by
            'order_by' => NULL,

            //offset
            'offset'  => 0,

            //The list of fields to be returned in the results
            'select_fields' => array( 'id'),

            //optional
            'link_name_to_fields_array' => array(array()),

            //Max number of results to list
            'max_results' => 20,

            'deleted' => false
        );

        $response = $this->call("get_entry_list", $get_entry_parameters);

然后我会喜欢每个帐户,检索他们的相关联系人,但我不知道我该怎么做。

1 个答案:

答案 0 :(得分:0)

我不知道出了什么问题,但这段代码现在正在制作我想要的东西。我没有正确定义相关数据的返回字段值。我应该在数组中定义它们。我想这是唯一的问题。如果其他人发现了另一个问题,请告诉我,因为我只是在学习糖/套装crms以及适合的地方。

function account_data()
    {
        $get_entry_parameters = array
        (
            //session id
            'session' => $this->session_id,

            //The name of the module from which to retrieve records
            'module_name' => "Accounts",

            //The ID of the record to retrieve.
            //'id' => NULL,

            //Where conditions without "where" keyword
            'query' => "accounts.assigned_user_id='" . $this->user_id . "'",

            //Sort result by
            'order_by' => NULL,

            //offset
            'offset'  => 0,

            //The list of fields to be returned in the results
            'select_fields' => array('id', 'name'),

            //optional
            'link_name_to_fields_array' => array(
                array(
                    'name' => 'contacts',
                    'value' => array('id', 'name')
                )
            ),

            //Max number of results to list
            'max_results' => 20,

            'deleted' => false
        );

        return $response = $this->call("get_entry_list", $get_entry_parameters);
}