function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger AccountTrigger1 on Account (After insert) {
List<Contact> Conlisttoupdate = new List<Contact>();
Map<Id,Account> MapofAccount = new Map<id,Account>();
if(trigger.isInsert && trigger.isAfter){
for(Account Acc:Trigger.new){
if(Acc.Total_No_of_Contacts__c != Null){
MapofAccount.put(Acc.Id, Acc);
}
for(Integer i = 0;i<MapofAccount.get(Acc.Id).Total_No_of_Contacts__c;i++){
contact Con = new Contact();
Con.AccountId = Acc.Id;
Con.LastName = Acc.Name + i;
Conlisttoupdate.add(Con);
}
}
If(!Conlisttoupdate.isEmpty()){
insert Conlisttoupdate;
}
}
}
Thanks,
Bhupal Kanakanti.