+ Start a Discussion
Parteek Goyal 3Parteek Goyal 3 

Address fields can only be filtered using Distance expressions

Hi All,

I want to search Contacts using this query.
List<Contact> listcontact=[SELECT id,name,phone from Contact where Lastname=:lname and MailingAddress=:mailingaddress];

But unexpectedly it give the error.
Address fields can only be filtered using Distance expressions
Please help me..
Best Answer chosen by Parteek Goyal 3
Vivek_PatelVivek_Patel
Hi Prateek,

Instead of compound field try to use individual fields MailingAddress.City, MailingAddress.Street etc. It should work.

Hope this helps!

Regards,
Vivek Patel.



 

All Answers

Vivek_PatelVivek_Patel
Hi Prateek,

Instead of compound field try to use individual fields MailingAddress.City, MailingAddress.Street etc. It should work.

Hope this helps!

Regards,
Vivek Patel.



 
This was selected as the best answer
Dinmukhamed Junussov 10Dinmukhamed Junussov 10

Hi Parteek Goyal,

By task description: The method searches for contacts that have a last name matching the first string and a mailing postal code (API name: MailingPostalCode) matching the second. It gets the ID and Name of those contacts and returns them. You should change from MailingAddress to MailingPostalCode.

Best regards,
Dinmukhamed Junussov

Mohd AshharMohd Ashhar
the correct API name for the fields are MailingCIty and MailingCountry