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
sgsssgss 

Any suggestion For this problem?

User-added image

What steps should i follow and how to solve this Can anyone help?
MagulanDuraipandianMagulanDuraipandian
Hi
You have to develop trigger on Contact object. Get substring between @ and .com. Find the account id using the account name.
--
Magulan Duraipandian
www.infallibletechie.com
sgsssgss
Can you explain in detail?
sgsssgss
So far I have come up with this: Can anyone resolve whats wrong and how can i fetch Id of account


trigger AssociateContact on Contact (before insert) {
    List<String> contactEmaildomains = new List<String>();
    for(Contact contact:Trigger.new){
        contactEmaildomains.add(contact.Email_Domain_Name__c);
    }

    List<Account> accounts = [
        SELECT 
            Id, Website_Domain_Name__c 
        FROM 
            Account
        WHERE 
            Website_Domain_Name__c IN :contactEmaildomains
    ];

    Set<String> accountWebsitedomains = new Set<String>();
    for(Account account:accounts){
        accountWebsitedomains.add(account.Website_Domain_Name__c);
    }

    for(Contact contact:Trigger.new){
        if(accountWebsitedomains.contains(contact.Email_Domain_Name__c)){
            contact.Account.Id = ??????(Need Account Id);
        }
    }
}