The below code searches on the lead record if the Account already exists in Salesforce using the website/email domain field. The code works just fine but I keep getting this error in my inbox: System.LimitException: Apex CPU time limit exceeded
Trigger Accname on Lead (before insert, before update) {
Account[] accts = [SELECT Name, id,Website,Domain__c FROM Account WHERE (Website != NULL OR Domain__c != NULL)];
for(Lead l : Trigger.new)
{
for(Integer i = 0; i < accts.size(); i++)
{
if(l.Domain__c == accts[i].Domain__c || l.Domain__c == accts[i].Website)
{
l.Account_Leads__c = accts[i].id;
l.Account_Found__c = True;
} else(System.debug('Not triggered.'));
}
}
}