Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void createContact(List<Account> accList){
- list<Contact> listContact = new list<Contact>();
- map<id,decimal> mapAcc = new map<id,decimal>();
- for(Account acc : accList){
- mapAcc.put(acc.id,acc.Number_Of_Location__c);
- system.debug('*********mapvalue'+mapAcc);
- }
- if(mapAcc.size()>0 && mapAcc!=null){
- for(id accId:mapAcc.keyset()){
- for(integer i=0;i<mapAcc.get(accId);i++){
- Contact con = new Contact();
- con.id=accId;
- con.LastName='contact'+i;
- listContact.add(con);
- }
- }
- }
- if(listContact.size()>0 && listContact!=null){
- insert listContact;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement