You need to sign in to do that
Don't have an account?
Sankar Landa 15
trigger AccountContact on Contact (before insert) {
List<Contact> cons=trigger.new;
for(integer i=1;i<trigger.new.size();i++){
for(Contact c:cons){
Account acc=[select id,Name from Account WHERE id=:c.Accountid];
system.debug('----------------test1--------:'+acc);
system.debug('----------------test1--------:'+i);
c.Description=acc.Name+'-'+'contact'+i;
system.debug('----------------test1--------:'+c.Description);
}
}
}
autopopulate contact description with account name as wiprocontact1 for the first contact,wiprocontact2 for second contact so on for a partcular account record.Below is my trigger code.please suggest me with correct logic.Thanks in advance
trigger AccountContact on Contact (before insert) {
List<Contact> cons=trigger.new;
for(integer i=1;i<trigger.new.size();i++){
for(Contact c:cons){
Account acc=[select id,Name from Account WHERE id=:c.Accountid];
system.debug('----------------test1--------:'+acc);
system.debug('----------------test1--------:'+i);
c.Description=acc.Name+'-'+'contact'+i;
system.debug('----------------test1--------:'+c.Description);
}
}
}
To achive this requirnment follow below steps;