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
NikithaNikitha 

hey I'm new to salesforce and triggers my trying to copy custom object fields values but im not coping. I dont know what happened help me in this

trigger CustomerDetailName on Customer_Detail__c (Before insert,after insert) {
    List<Dup_Customer_Detail__c> dupList = new List<Dup_Customer_Detail__c>();
    for(Customer_Detail__c customer : trigger.new){
        if(trigger.IsBefore && trigger.isInsert){
        customer.Name= customer.Name + '.' + customer.Last_name__c;
    }
      else  if(trigger.IsAfter && trigger.isInsert){
        Dup_Customer_Detail__c dup =new Dup_Customer_Detail__c();
        dup.Name = customer.Name;
        dup.Last_Name__c = customer.Last_name__c;
        
        dupList.add(dup);
    
    }
  
    }
    if(!dupList.isEmpty()){
    insert dupList;
    }
Lukesh KarmoreLukesh Karmore
trigger CustomerDetailName on Customer_Detail__c(After insert) {
list<Dup_Customer_Detail__c>  dupList =new list<Dup_Customer_Detail__c>();
    for(Customer_Detail__c customer:trigger.new){
        if(Customer_Detail__c.Name!= null && Customer_Detail__c.Last_Name__c!= null){
           Dup_Customer_Detail__c dup=new Dup_Customer_Detail__c();
            dup.Name=customer.Name;
            dup.Last_Name__c=customer.Last_Name__c;
            dupList.add(dup);
           }
        }
}
 IT HELPS  YOU MARK THE BEST ANSWER THANK YOU.