function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jordan BlairJordan Blair 

Is it possible to update multiple records with matching email addresses?

Theas records live on the same object.  For example, when a contact 1 checkbox A is changed I need to update checkbox A on all contacts who email match contact A.  I know this is possible with trigger, however, I just need someone to help get me started.

Thanks
Dadi Prak DadiDadi Prak Dadi
Yes you can.You Just need a SOQL query and grab all contacts which have similar email

String emailToCheck = //Put your email here
List<Contact> needUpdateList = [Select Checkbox__C from Contact where Email =: emailToCheck];
List<Contact> updateRecords = new List<Contact>();
for(Contact con: needUpdateList){
con.CheckBox__c = True/False;
updateRecords .add(con);
}

update updateRecords;
AbhishekAbhishek (Salesforce Developers) 
Hi,

Let's say if a Contact X has email: abcd123@gmail.com and that contains a checkbox field as selected, If you want to update checkbox on all contacts who contain the email as same then yes it is possible from the apex.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.
Dadi Prak DadiDadi Prak Dadi
Small change there is a syntac error

String emailToCheck = //Put your email here
List<Contact> needUpdateList = [Select Id,Checkbox__C from Contact where Email =: emailToCheck];
List<Contact> updateRecords = new List<Contact>();
for(Contact con: needUpdateList){
con.CheckBox__c = True/False;
updateRecords .add(con);
}

update updateRecords;