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
raju p 4raju p 4 

i have little doubt i aim created chiled to parent record in trigger its not working

public class WhenyouCreateContactCreateAccount {
       
    public static void CreateAccount(list<contact>cons){
         set<id>ids= new set<id>();
         list<account>acc= new list<account>();
      
            for(contact c:cons){
               ids.add(c.AccountId);
  acc=[select name,phone from account where id IN:ids];
                for(account a:acc){

    a.Name=c.Name;
   a.Phone=c.phone;
 
}
 insert  acc;
}
    }}



trigger WhenyouCreateContactCreateAccount on Contact (after insert,after update) {
    WhenyouCreateContactCreateAccount.CreateAccount(trigger.new);

}

please do the needful, where i am doing wrong
raju p 4raju p 4
Hi,
Arvind Kumar,

 Not working code,  i tryied many ways this one also
 
Arvind KumarArvind Kumar
Hi Raju,

Did get your required solution?

If not, please let me know your exact requirement.So that i can help you and give a better solution.

Thanks,
Arvind Kumar