我试图根据糖crm中的联系人ID访问帐户详细信息?但它返回Access denied对象

时间:2014-10-03 10:05:09

标签: sugarcrm

我写了以下查询:

var account_query = "accounts.id IN ( SELECT account_id FROM  accounts_contacts WHERE  contact_id='"+ id +"')";

id是联系人ID

请给我解决方案..

1 个答案:

答案 0 :(得分:0)

您可以这样做:

此示例是加载联系人并获取其父帐户:

//Load Contact
$bean = BeanFactory::getBean('Contacts', $id);

//If relationship is loaded
if ($bean->load_relationship('accounts'))
{
    //Fetch related beans 
    $relatedBeans = $bean->accounts->getBeans();

    $parentBean = false;
    if (!empty($relatedBeans))
    {
        //order the results
        reset($relatedBeans);

        //first record in the list is the parent
        $parentBean = current($relatedBeans);
    }
}

Check This Link 1 Check This Link 2