SugarCRM:获取来自Opportunties的报价

时间:2016-06-29 08:08:16

标签: php api sugarcrm

我正在尝试获取与机会相关的行情。 This link应该帮助我,但它没有。

我会尽可能清楚地解释我想要什么以及我尝试过什么。

我想要的:我打电话给我们的SugarCRM实例以获取机会,当他们具有指定状态时,我想要获得与该机会相关的报价。

我尝试过:

我打电话获取机会:

$opportunities = $service->getList('Opportunities');

比我使用foreach循环:

    foreach ($opportunities->entry_list as $opportunity)
    {
        if($opportunity->name_value_list->sales_stage->value == 'Closed Won')
            $quotes = $service->getRelatedList($opportunity->module_name, $opportunity->id, 'AOS_Quotes');

        echo '<pre>';
        var_dump($quotes);
        echo '</pre>';

    }

函数getRelatedList如下所示:

public function getRelatedList($module, $id, $related_module)
{
    $get_entry_list_parameters = array(
        //session id
        'session' => $some_session,
        'module_name' => $module,
        'module_id' => $id,
        'link_field_name' => $related_module,
        'related_module_query' => '',
        'related_fields' => array(
            'id',
            'name',
        ),
        'query' => '',
        'order_by' => '',
        'offset' => 0,
        //A list of fields to include in the results.
        'select_fields' => array(
            'id',
        ),
        'deleted' => 0,
        'favorites' => false,
    );

    $entries = $this->sendRequest('get_relationships', $get_entry_list_parameters);

    return $entries;
}

这是我对每个引语的结果:

object(stdClass)#5051 (2) {
  ["entry_list"]=>
  array(0) {
  }
  ["relationship_list"]=>
  array(0) {
  }
}

但这是什么意思?这不是我想要/期望的,但我应该期待什么,我做错了什么?

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

Oke ......解决方案非常简单且非常棒。问题是,在尝试搜索正确的解决方案时,我混合了一些例子。这导致混合参数列表中的字段,导致输出错误。