I have to write a query where all conditions should match at the same time.
Account
has 3 custom fields: Country__c
, State__c
, and Customer__c
(look up to Customer_Account__c
object).
The Customer_Account__c
object also has a 2 custom fields (Country__c
and State__c
).
Whenever I create an Account
record, it will first check if any Customer_Account__c
record exists in our database based on country and state. If yes, then map that record (Customer_Account__c
) to Account__c.Customer__c
. If not, create a new one.
I can deal with mapping Customer_Account__c
to Account
. But I am having difficulty with how to query Customer_Account__c
record with matching Account
field values.
Example:
If an Account
has Country__c = 'Australia'
and State__c = 'Brisbane'
, then it will query Customer_Account__c
records where Country__c = 'Australia'
and State__c = 'Brisbane'
.
Both conditions should match together. And of course we are bulkifying the trigger.