0
votes

I already have contact by using Accountid, so before creating the new contact I want to verify the existing contact with email and id, can you please help me with this salesforce query to check if the Contact already exist with Contact Email and AccountId?

I already tried using the below query but it was throwing exceptions:

SELECT Id, Name , email 
FROM Contact
WHERE email='[email protected]'
AND Id IN (SELECT ContactId
   FROM AccountContactRelation
   WHERE AccountId = 'XXXX')

Got the below error:

INVALID_TYPE: and Id IN (SELECT ContactId FROM AccountContactRelation WHERE AccountId ^

ERROR at Row:1:Column:121 sObject type 'AccountContactRelation' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

Can you please share the correct Salesforce Query ?

1

1 Answers

0
votes

The below Query worked like charm :)

SELECT Id, Name , email 
FROM Contact 
WHERE email='[email protected]' 
      AND AccountId='[email protected]'