AnsweredAssumed Answered

Filters using OR operation and filter populate

Question asked by Ben Selby on Aug 24, 2016
Latest reply on Aug 24, 2016 by Ben Selby

Does anybody know if it is possible to do an OR operation in a filter definition that we then use with filter_relate?

 

We have customised the Cases module, and we have a relate field with Contacts. We want to search the contacts, that are linked to the account we have picked on the Case. But also, add another contact record, all the time.

 

We currently have

 

```

$viewdefs['Contacts']['base']['filter']['basic']['filters'][] = [
    'id' => 'contactsForAccountForReportedBy',
    'name' => 'LBL_FILTER_CONTACTS_FOR_ACCOUNT',
    'filter_definition' => [
        [
            '$or' => [
                'account_id' => '',
                'id' => [
                    '$equals' => '1e40cf4a-615d-11e5-82a3-00155daa9e14'
                ]
            ]
        ]
    ],
    'editable' => true,
    'is_template' => true,
    'default' => false,
];

```

But we get currently get this error:

 

```
Unknown field $in

```

 

The API request going into SugarCRM is this (Query String):

 

```

filter[0][$and][0][$or][account_id][$in][]:733354c3-6938-11e6-ba70-0800278493db
filter[0][$and][0][$or][id][$equals]:1e40cf4a-615d-11e5-82a3-00155daa9e14
filter[0][$and][1][$or][0][first_name][$starts]:%4
filter[0][$and][1][$or][1][last_name][$starts]:%4
fields:id,name,phone_work,email1,preferred_method_of_contact_c,account_id,account_name
max_num:5

```

 

Anyone know if this is possible?

Outcomes