You need to sign in to do that
Don't have an account?
Akash Choudhary 17
Required help to bulkify this code
Hi All,
I need to bulkify this code please help.
public class Move_Contact {
public static void updateContact(List <Contact> conList){
Map <Id,Id> conMap = new Map <Id,Id>();
for(Contact myCon : conList){
if(myCon.Email != null){
string domain = myCon.Email.split('@').get(1);
String MainDomain = domain;
string website ='www.' +MainDomain;
string httpWebsite ='http://www.' + MainDomain;
string httpswebsite ='https://www.'+ MainDomain;
string international = MainDomain + '.%';
Account acc = [SELECT Id
FROM Account
WHERE Website =:website
or Website =:httpWebsite
or Website =:httpswebsite
or Website =:international Limit 1];
myCon.AccountId = acc.Id ;
}
}
}
}
Thanks
I need to bulkify this code please help.
public class Move_Contact {
public static void updateContact(List <Contact> conList){
Map <Id,Id> conMap = new Map <Id,Id>();
for(Contact myCon : conList){
if(myCon.Email != null){
string domain = myCon.Email.split('@').get(1);
String MainDomain = domain;
string website ='www.' +MainDomain;
string httpWebsite ='http://www.' + MainDomain;
string httpswebsite ='https://www.'+ MainDomain;
string international = MainDomain + '.%';
Account acc = [SELECT Id
FROM Account
WHERE Website =:website
or Website =:httpWebsite
or Website =:httpswebsite
or Website =:international Limit 1];
myCon.AccountId = acc.Id ;
}
}
}
}
Thanks
All Answers
It is still not working the acc.Id in 32nd line is out of For loop of account , so it does not exist. Hence the code is not working. kindly please suggest something else
Thanks
The code is still not working here is the error : Apex trigger MoveContact caused an unexpected exception, contact your administrator: MoveContact: execution of AfterInsert caused by: System.FinalException: Record is read-only: Class.Move_Contact.updateContact: line 32, column 1.
Can we do something about it?
Thanks.
Finally working !. Thanks a ton. you are awesome.
Thanks