SugarCrm按帐户名称和名称查找商机

时间:2013-04-16 19:10:12

标签: sugarcrm

我已完成此查询以根据帐户名称和名称查找商机:

public function getOpportunity($session_id, $client, $email, $name){

        $acc = $this->getAccount($session_id, $client, $email);
        $acc_id = $acc->entry_list[0]->id;
        $query2 = " 
                            opportunities.id in
                            (select accounts_opportunities.opportunity_id from
                            accounts_opportunities inner join
                            accounts where
                                                    accounts_opportunities.account_id = accounts.id and
                                                    accounts_opportunities.deleted = 0 and
                                                    accounts.deleted = 0 and
                                                    accounts.id = '{$acc_id}')
                            and opportunities.deleted=0
                            and opportunities.name = '{$name}'";

        $op = $client->get_entry_list($session_id, 'Opportunities', $query2);

        return $op;
    }

出于某种原因,它正在返回错误,错误的erro 40访问被拒绝。我不知道为什么这个查询不起作用。我做了一个类似的,通过电子邮件找到帐户,它成功地返回我想要的结果没有任何错误。该查询如下:

    public function getAccount($session_id, $client, $email){

        $query = "accounts.id in 
( select bean_id from 
email_addr_bean_rel inner join
email_addresses where 
email_addr_bean_rel.email_address_id = email_addresses.id 
and email_addr_bean_rel.deleted = 0 and
email_addresses.deleted = 0 and 
bean_module = 'Accounts' and
email_addresses.email_address = '{$email}' )";

        $acc = $client->get_entry_list($session_id, 'Accounts', $query);
        return $acc;   
    }

任何帮助将不胜感激。谢谢。

编辑:我正在使用SOAP API和PHP。

1 个答案:

答案 0 :(得分:0)