You need to sign in to do that
Don't have an account?
Nikitha
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;
}
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;
}
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.