Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public static void createContact(List<Account> accList){
  2.  
  3. list<Contact> listContact = new list<Contact>();
  4. map<id,decimal> mapAcc = new map<id,decimal>();
  5.  
  6. for(Account acc : accList){
  7. mapAcc.put(acc.id,acc.Number_Of_Location__c);
  8. system.debug('*********mapvalue'+mapAcc);
  9. }
  10. if(mapAcc.size()>0 && mapAcc!=null){
  11. for(id accId:mapAcc.keyset()){
  12. for(integer i=0;i<mapAcc.get(accId);i++){
  13.  
  14. Contact con = new Contact();
  15. con.id=accId;
  16. con.LastName='contact'+i;
  17. listContact.add(con);
  18. }
  19. }
  20. }
  21. if(listContact.size()>0 && listContact!=null){
  22. insert listContact;
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement