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
arjuna Rajput 29arjuna Rajput 29 

can anyone help me out to in belows code that to check account name is equals to domain if it matches domain name value assign to account name

public class ContactEmailHelper {
    public static void onBeforeInsert(Contact ct)
    {
         Set<String> emailDomains = new Set<String>();
        String Domain;
        if(ct.email!=null)
        {
            Domain=(ct.Email.split('@').get(1)); 
            emailDomains.add(Domain.replace('.com',''));
        }
       List<Account> acc= new List<Account>([select id,Name from Account where Name in :emailDomains]);
// what i write after here to check that my domain name matches to account name if it matches then assign domain name to contact
    
    
    }
  

}
PriyaPriya (Salesforce Developers) 

Hey Arjuna,

Here to check the matching account, you need to store the Account value in Map. 

You can refer the below code which is written to find duplicate and try modify yours accordingly :- 

https://developer.salesforce.com/forums/?id=906F0000000fyhvIAA

Kindly mark it as the best answer, If it helps.

Regards,

Priya Ranjan

mukesh guptamukesh gupta
Hi Arjuna,

Your question is not correct, please chekc and update

Regards
arjuna Rajput 29arjuna Rajput 29
Hello mukesh,

Question is that
we wanto extract domain name from email abc@gmail.com----extracted name is gmail so after that we will check this domain name we got gmail matches to any account then assign domain name to account name....we result we get whenever we create a new contact fill emial field then what we see account name feild of contact automatically fill with domain name beacause idomain name matches to account name