Reputation: 499
I am integrating SugarCRM 9.0 using v11 API service. I am struggling quite long now to filter contact's with given email address. As per the new SugarCRM the email addresses of contact are obtained under the field named email
, which is an array.
Request endpoint: https://mysugarcrm.org/rest/v11/Contacts/filter
Input filter array:
[
"filter" => [[
'email1' => '[email protected]'
]]
]
Here you can see I am passing email#
as filter argument which only works for primary email address, but when a contact has more than one email address added to it then how to create the filter? I tried few combinations with the help of sub-expressions $contains
and $in
but none of those helped.
For better picture, here is the sample email array than we get in contact record without filter -
[
{
"id": "c02c12c3-4569-3456-xxxxxxxxx",
"first_name": "test",
"last_name": "test"
"email": [
{
"email_address": "[email protected]",
"primary_address": true,
"reply_to_address": false,
"invalid_email": false,
"opt_out": false,
"email_address_id": "b11h2344-4568-xxxx-xxxxxxxxxxx"
},
{
"email_address": "[email protected]",
"primary_address": false,
"reply_to_address": false,
"invalid_email": false,
"opt_out": false,
"email_address_id": "b11h2344-4568-xxxx-xxxxxxxxxxx"
},
{
"email_address": "[email protected]",
"primary_address": false,
"reply_to_address": false,
"invalid_email": false,
"opt_out": false,
"email_address_id": "b11h2344-4568-xxxx-xxxxxxxxxxx"
}
],
"module": "Contacts"
},
{
....
},
{
....
}
]
Here you can see, email
is an array of objects which I want to filter based on email_address.
Upvotes: 0
Views: 238
Reputation: 499
I came across a solution for this.
There is actually a filter field at behind the picture called email_addresses
, which we can use to add filter. Here is my new filter array -
[
"filter" => [[
"email_addresses.email_address":"[email protected]"
]]
]
So wherever you have to fetch data from the field of type email, use this solution. Works with every module.
Upvotes: 1