如何在子字段上搜索或过滤SugarCRM REST API

时间:2017-09-01 20:38:37

标签: php sugarcrm

这似乎是一件简单的事情,但我无法让它发挥作用。我正在查询/ Users端点,并且我试图通过电子邮件地址过滤用户。

当我在没有过滤器的情况下调用端点时,我会得到类似的结果:

    "records": [
        {
          "id": "abc123",
          "user_name": "brad",
          "first_name": "Brad",
          ...
          "email1": "",
          "email": [
            {
              "email_address": "brad@email.com",
              "primary_address": true,
              "reply_to_address": false,
              "invalid_email": false,
              "opt_out": false
            }
          ],
          ...

我试图过滤电子邮件地址。我试过了:

    $filters = [
        'filter' => [
            [
                'email.email_address' => [
                    '$contains' => 'brad'
                ]
            ]
        ]
    ];

但是我收到了这个错误:

    {"error":"invalid_parameter","error_message":"Invalid link email for field email_address"}

我可以按user_name =' brad'过滤它工作得很好,但是当我试着深入1级时就不行了。

1 个答案:

答案 0 :(得分:1)

必须直接向SugarCRM支持发送电子邮件。

而不是:

    $filters = [
        'filter' => [
            [
                'email.email_address' => [
                    '$contains' => 'brad'
                ]
            ]
        ]
    ];

我需要使用email_addresses.email_address:

    $filters = [
        'filter' => [
            [
                'email_addresses.email_address' => [
                    '$contains' => 'brad'
                ]
            ]
        ]
    ];