• Ankit Bobde
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
trigger TriggerAccountContacts on Account (after insert) {
list<contact> cons=new list<contact>();
    for(account a:trigger.new){
        contact c=new contact();
        c.lastname=a.name;
        c.Phone=a.phone;
        c.Description=a.description;
        c.AccountId=a.id; //what is accountid here is it record id of account object
        cons.add(c);
    }
    insert cons;
}
Here is my test class

Here is my test class
 
@isTest
private class TestAMCLeadCreationBatch {

   static testMethod void myUnitTest() {
       
        list<Lead> tempLead = new list<Lead>();
        list<smagicinteract__smsMagic__c> smsObjectList = new list<smagicinteract__smsMagic__c>();
        
        User u = [Select id
                     from
                     User
                     where
                     name='Balamurugan Nadar'];
        system.runAs(u)
        {    
            Profile p = [select id
                                from
                                Profile
                                where
                                name='BMCC system Admin SSO'];
                                     
             User uBDE = new user(alias = 'test1234', email='test1234@noemail.com',related_team__c = 'BDE', Service_Segment__c ='Compliance Services',
                                emailencodingkey='UTF-8', firstName='Piyush', lastname='Pakhale', languagelocalekey='en_US', MobilePhone='9789654123',
                                localesidkey='en_IN', profileid = p.Id, country='India', Registration__c = true,
                                timezonesidkey='Asia/Kolkata', username='test_g@noemail.com');
            insert uBDE;
            
            Contact tempContact = new Contact();
            tempContact.Salutation='Mr.';
            tempContact.FirstName='Ankit';
            tempContact.LastName='Bobde';
            tempContact.Email='ankit.bobde@bmcgroup.in';
            insert tempContact;

           Operation__c tempOperation= new Operation__c();
            tempOperation.contact__c=tempContact.id;
            tempOperation.Enquiry_for__c='Pvt. Ltd. Registration';
            tempOperation.ROC_Name__c = 'Maharashtra';
            tempOperation.Incorporation_Date__c=system.today();
            tempOperation.Auth_Capital__c=1000;
            tempOperation.Paid_Up_Capital__c=1000;
            tempOperation.Name='BMCTEST';
            tempOperation.New_Company_Name__c='ABC';
            insert tempOperation;
            
            tempOperation.Auth_Capital__c=2000;
            tempOperation.isBulkcreated__c=true;
            update tempOperation;
            
            
            
            for(integer i=0; i<100; i++){
                Lead scheduleLead = new Lead();
                scheduleLead.Enquiry_For__c =  'Pvt. Ltd. AMC';
                scheduleLead.LastName='.';
                scheduleLead.Company='.';
                scheduleLead.ownerId = uBDE.id;
                scheduleLead.Created_Through__c = 'BDE';
                tempLead.add(scheduleLead);    
            
            }
            insert tempLead;
            
       
            test.startTest();
        
            AMCLeadCreationBatch lrbs = new AMCLeadCreationBatch();
            id batchProcessID = Database.executeBatch(lrbs);
        
            test.stopTest();
        }
    }
}

Any Help would be appreciated
 
My test class is giving an error as attempt to dereference a null object..... external entry point

here is my class /*
* This class is created to Create bulk Leads  
* Taking data from previous operations Client
* The required Operations Client's data is given through Custom Settings @line 32
* Created By Ankit
*/

global class AMCLeadCreationBatch implements Database.Batchable<sObject>,Database.AllowsCallOuts,Database.Stateful {
    
    global string query;
    global string mobile, rocName,phoneNumber, ownerName,enquiryFor,ownerEmail, leadContact, smsTemplate='', todaydt,enqFor,newLeadEnquiryFor;
    global DateTime dt, scheduleDate;
    global date todayDate,toDate,fromDate;
    Integer limitNo,tempSize=0,maxSize;
    list<Lead> newLeadList = new list<Lead>();
    list<Lead> listOfLeads = new list<Lead>();
    list<Operation__c> newOperationList = new list<Operation__c>();
    //list<id> userIDs = new list<Id>{'00590000000myQN','00590000000myQm','00590000000oVw0'};
    list<String> userIDs = new list<String>();
    String idStrings;
    String userInLoopID=null;
    String tempUserId;
    
    global AMCLeadCreationBatch(){
        dt = system.now();  
        todayDate = dt.date();
        //todayDate = date.newInstance(dt.year(), dt.month(), dt.day());
        todayDt = date.today().format();
     
        system.debug('-todayDt-' + todayDt+'-todayDate-'+ todayDate);
        
       for(BulkLeadCreation__c newList: [Select ROC_Name__c,New_Lead_Enquiry_For__c,From_Date__c,To_Date__c,UserIDs__c,Enquiry_For__c,Limit__c from BulkLeadCreation__c where Name = '1']){
            Integer tempInt;
            newLeadEnquiryFor = newList.New_Lead_Enquiry_For__c;
            enqFor = newList.Enquiry_For__c;
            tempInt = Integer.valueof(newList.Limit__c);
            limitNo = tempInt;
            idStrings = newList.UserIDs__c;
            fromDate = newList.From_Date__c;
            toDate = newList.To_Date__c;
            if(newList.ROC_Name__c != null){
                rocName = newList.ROC_Name__c;
            }
        }
        if(idStrings != null){
            userIDs=idStrings.split(',');
        }
        system.debug('-userIDs from CS-'+userIDs+userIDs.size());
        
          
          listOfLeads = [Select isBulkcreated__c,isConverted,BMCID__c from lead where isBulkcreated__c=:true AND Enquiry_For__c =: newLeadEnquiryFor AND isConverted=:false  AND Created_Date__c < :system.today()-365];
          system.debug('-listOfLeads-'+listOfLeads+listOfLeads.size());
          set<String> stringList= new set<String>();
          string BMCIDString;
         // system.debug('-system.today()-365-'+system.today()-365);
          
          if(listOfLeads.size()>0){
              for(Lead tempList : listOfLeads){
                  BMCIDString = tempList.BMCID__c;
                  stringList.add(BMCIDString);
                  system.debug('-stringList-'+stringList);
              }
          }
          system.debug('-stringList out of the loop-'+stringList+stringList.size());
          
          newOperationList = [Select isBulkCreated__c from Operation__c where Name IN : stringList];
          list<operation__c> tempOpList = new list<Operation__c>();
          system.debug('-newOperationList-'+newOperationList+newOperationList.size());
          
          if(newOperationList.size()>0){
              for(Operation__c tempOp:newOperationList){
                  tempOp.isBulkCreated__c = false;
                  tempOpList.add(tempOp);
              }
          }
          system.debug('-tempOpList-'+tempOpList+tempOpList.size());
          if(tempOpList.size()>0){
              update tempOpList;
          }
    }
    
    global Database.Querylocator start(Database.BatchableContext bc){
        
        
        if(rocName!=null)
        {
            query ='Select id,Contact_Name__c,ContactCCEmail__c,Contact_Email__c,Phone_Number__c,Enquiry_for__c,Contact_FirstName__c,Contact_LastName__c,Contact_Salutation__c,'+
               'City__c,ROC_Name__c,Incorporation_Date__c,Auth_Capital__c,Paid_Up_Capital__c,'+
               'Name,New_Company_Name__c,Company_Extention__c,CreatedDate,Owner_Name__c,BDE_Name__c from Operation__c'+
               ' where Enquiry_for__c =: enqFor AND Incorporation_Date__c >= :fromDate AND Incorporation_Date__c <= :toDate AND ROC_Name__c =:rocName limit : limitNo';
        }else{
            query ='Select id,Contact_Name__c,ContactCCEmail__c,Contact_Email__c,Phone_Number__c,Enquiry_for__c,Contact_FirstName__c,Contact_LastName__c,Contact_Salutation__c,'+
               'City__c,ROC_Name__c,Incorporation_Date__c,Auth_Capital__c,Paid_Up_Capital__c,'+
               'Name,New_Company_Name__c,Company_Extention__c,CreatedDate,Owner_Name__c,BDE_Name__c from Operation__c'+
               ' where Enquiry_for__c =: enqFor AND Incorporation_Date__c >= :fromDate AND Incorporation_Date__c <= :toDate limit : limitNo';
        }
                         
        system.Debug('---in CLass Query contains Before return statement---'+ query);
        return Database.getQueryLocator(query);               
    }
    
    global void execute(Database.BatchableContext bc, list<Operation__c> scope){
        try{
            
            list<Operation__c> newOpList = new list<Operation__c>();
            list<Operation__c> updateOpList =new list<Operation__c>();
            
            newOpList = [Select id,isBulkCreated__c from Operation__c where id IN : scope];
            
            for(Operation__c opList: newOpList){
                opList.isBulkCreated__c = true;
                updateOpList.add(opList);
            }
            update updateOpList;
            system.debug('--updateOpList--'+updateOpList);
            
            System.debug('---Scope--'+ Scope);
            dt = system.now();
            todayDate = date.newInstance(dt.year(), dt.month(), dt.day());
            for(Operation__c scheduledoperation : scope){
                
                Lead newLead = new Lead();
                Integer size=userIDs.size();
                boolean flag=false;
                
                for(String tempId:userIDs){
                    tempSize=tempSize+1;
                    if(userIDs.size()==1){
                        tempSize=0;
                    }
                    system.debug('--tempSize--'+tempSize);
                    if(userInLoopID==tempId){
                        newLead.User__c = userIDs.get(tempSize);
                        newLead.OwnerID = userIDs.get(tempSize);
                        userInLoopID = userIDs.get(tempSize);
                        if(tempSize==userIDs.size()-1){
                            maxSize=1;
                            system.debug('-maxSize-'+maxSize);
                        }
                        system.debug('-tempSize-'+tempSize);
                        tempSize=0;
                        flag=true;
                        break;
                    }
                }
                if(flag==false){
                        newLead.User__c = userIDs.get(0);
                        newLead.OwnerID = userIDs.get(0);
                        userInLoopID=userIDs.get(0);
                        tempSize=0;
                        maxSize=0;
                        system.debug('-userInLoopID in else if-'+userInLoopID);
                }
                
                if(maxSize==1){
                    userInLoopID=null;
                    system.debug('-userInLoopID-'+userInLoopID);
                }
                
                newLead.Salutation = scheduledoperation.Contact_Salutation__c;
                newLead.CCEmail__c=scheduledoperation.ContactCCEmail__c;
                newLead.LastName = scheduledoperation.Contact_LastName__c;
                newLead.FirstName = scheduledoperation.Contact_FirstName__c;
                newLead.Contact_Name__c = scheduledoperation.Contact_Name__c;
                newLead.Email = scheduledoperation.Contact_Email__c;
                newLead.Phone = scheduledoperation.Phone_Number__c;
                newLead.Enquiry_For__c = newLeadEnquiryFor;
                newLead.Created_Through__c = 'BDE';
                newLead.WorkFlowNumber__c = 1;
                newLead.CompliancePage__c = true;
                newLead.City = scheduledoperation.City__c;
                newLead.ROC_Name__c = scheduledoperation.ROC_Name__c;
                newLead.Incorporation_Date__c = scheduledoperation.Incorporation_Date__c;
                newLead.Auth_Capital__c = scheduledoperation.Auth_Capital__c;
                newLead.Paid_up_Capital__c = scheduledoperation.Paid_Up_Capital__c;
                newLead.BMCID__c = scheduledoperation.Name;
                newLead.Operation_owner__c = scheduledoperation.Owner_Name__c;
                newLead.Operations_Created_Date__c = scheduledoperation.createdDate;
                newLead.Company = scheduledoperation.New_Company_Name__c +' '+scheduledoperation.Company_Extention__c;
                newLead.BDE_Name__c = scheduledoperation.BDE_Name__c;
                newLead.isBulkcreated__c = true;
                newLeadList.add(newLead);
                
          }
    
    
        Database.SaveResult[] srList = Database.insert(newLeadList,false);
        for(Database.SaveResult sr : srList){
            if(sr.isSuccess()){
                system.debug('Successfully inserted Transaction. Transaction ID: ' + sr.getID());
            }
            else{
                for(Database.Error err : sr.getErrors()){
                    System.debug('The following error has occurred.');
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Transaction fields that affected this error: ' + err.getFields());

                }
            }
        }
        
        }catch(exception e){
            system.debug('--Exception--'+ e.getMessage());
        }  
         
    }
    
    global void finish(Database.BatchableContext BC){
        AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email
                                          from
                                          AsyncApexJob
                                          where
                                          Id =:BC.getJobId()];
         
         system.debug('--Batch Job contains--' + a);
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
         String[] toAddresses = new String[] {'ankit.bobde@bmcgroup.in'};
         mail.setToAddresses(toAddresses);
         mail.setSubject('Bulk : Lead Creation Batch ' + a.Status);
         mail.setPlainTextBody
         ('The batch Apex job processed ' + a.TotalJobItems +
          ' batches with '+ a.NumberOfErrors + ' failures.');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        
     }
      
    

}

 
Hello,
I have a Text Area Field in  one of my custom Settings.
I want to pass some id's (say 10) into the TEXT AREA FIELD comma seperated and after that I want to get those id's into a single list so that I can iterate over it and Assign users using that ids.
Any help would be appreciated
there is a record with owner 'x' and and owner changed to 'y' and if the owner 'y' remains owner for 30 days. and after 30 days need to create a record on the child object.

Any help would be greatly appriciated. Thanks in advance

 
  • August 22, 2015
  • Like
  • 0
My test class is giving an error as attempt to dereference a null object..... external entry point

here is my class /*
* This class is created to Create bulk Leads  
* Taking data from previous operations Client
* The required Operations Client's data is given through Custom Settings @line 32
* Created By Ankit
*/

global class AMCLeadCreationBatch implements Database.Batchable<sObject>,Database.AllowsCallOuts,Database.Stateful {
    
    global string query;
    global string mobile, rocName,phoneNumber, ownerName,enquiryFor,ownerEmail, leadContact, smsTemplate='', todaydt,enqFor,newLeadEnquiryFor;
    global DateTime dt, scheduleDate;
    global date todayDate,toDate,fromDate;
    Integer limitNo,tempSize=0,maxSize;
    list<Lead> newLeadList = new list<Lead>();
    list<Lead> listOfLeads = new list<Lead>();
    list<Operation__c> newOperationList = new list<Operation__c>();
    //list<id> userIDs = new list<Id>{'00590000000myQN','00590000000myQm','00590000000oVw0'};
    list<String> userIDs = new list<String>();
    String idStrings;
    String userInLoopID=null;
    String tempUserId;
    
    global AMCLeadCreationBatch(){
        dt = system.now();  
        todayDate = dt.date();
        //todayDate = date.newInstance(dt.year(), dt.month(), dt.day());
        todayDt = date.today().format();
     
        system.debug('-todayDt-' + todayDt+'-todayDate-'+ todayDate);
        
       for(BulkLeadCreation__c newList: [Select ROC_Name__c,New_Lead_Enquiry_For__c,From_Date__c,To_Date__c,UserIDs__c,Enquiry_For__c,Limit__c from BulkLeadCreation__c where Name = '1']){
            Integer tempInt;
            newLeadEnquiryFor = newList.New_Lead_Enquiry_For__c;
            enqFor = newList.Enquiry_For__c;
            tempInt = Integer.valueof(newList.Limit__c);
            limitNo = tempInt;
            idStrings = newList.UserIDs__c;
            fromDate = newList.From_Date__c;
            toDate = newList.To_Date__c;
            if(newList.ROC_Name__c != null){
                rocName = newList.ROC_Name__c;
            }
        }
        if(idStrings != null){
            userIDs=idStrings.split(',');
        }
        system.debug('-userIDs from CS-'+userIDs+userIDs.size());
        
          
          listOfLeads = [Select isBulkcreated__c,isConverted,BMCID__c from lead where isBulkcreated__c=:true AND Enquiry_For__c =: newLeadEnquiryFor AND isConverted=:false  AND Created_Date__c < :system.today()-365];
          system.debug('-listOfLeads-'+listOfLeads+listOfLeads.size());
          set<String> stringList= new set<String>();
          string BMCIDString;
         // system.debug('-system.today()-365-'+system.today()-365);
          
          if(listOfLeads.size()>0){
              for(Lead tempList : listOfLeads){
                  BMCIDString = tempList.BMCID__c;
                  stringList.add(BMCIDString);
                  system.debug('-stringList-'+stringList);
              }
          }
          system.debug('-stringList out of the loop-'+stringList+stringList.size());
          
          newOperationList = [Select isBulkCreated__c from Operation__c where Name IN : stringList];
          list<operation__c> tempOpList = new list<Operation__c>();
          system.debug('-newOperationList-'+newOperationList+newOperationList.size());
          
          if(newOperationList.size()>0){
              for(Operation__c tempOp:newOperationList){
                  tempOp.isBulkCreated__c = false;
                  tempOpList.add(tempOp);
              }
          }
          system.debug('-tempOpList-'+tempOpList+tempOpList.size());
          if(tempOpList.size()>0){
              update tempOpList;
          }
    }
    
    global Database.Querylocator start(Database.BatchableContext bc){
        
        
        if(rocName!=null)
        {
            query ='Select id,Contact_Name__c,ContactCCEmail__c,Contact_Email__c,Phone_Number__c,Enquiry_for__c,Contact_FirstName__c,Contact_LastName__c,Contact_Salutation__c,'+
               'City__c,ROC_Name__c,Incorporation_Date__c,Auth_Capital__c,Paid_Up_Capital__c,'+
               'Name,New_Company_Name__c,Company_Extention__c,CreatedDate,Owner_Name__c,BDE_Name__c from Operation__c'+
               ' where Enquiry_for__c =: enqFor AND Incorporation_Date__c >= :fromDate AND Incorporation_Date__c <= :toDate AND ROC_Name__c =:rocName limit : limitNo';
        }else{
            query ='Select id,Contact_Name__c,ContactCCEmail__c,Contact_Email__c,Phone_Number__c,Enquiry_for__c,Contact_FirstName__c,Contact_LastName__c,Contact_Salutation__c,'+
               'City__c,ROC_Name__c,Incorporation_Date__c,Auth_Capital__c,Paid_Up_Capital__c,'+
               'Name,New_Company_Name__c,Company_Extention__c,CreatedDate,Owner_Name__c,BDE_Name__c from Operation__c'+
               ' where Enquiry_for__c =: enqFor AND Incorporation_Date__c >= :fromDate AND Incorporation_Date__c <= :toDate limit : limitNo';
        }
                         
        system.Debug('---in CLass Query contains Before return statement---'+ query);
        return Database.getQueryLocator(query);               
    }
    
    global void execute(Database.BatchableContext bc, list<Operation__c> scope){
        try{
            
            list<Operation__c> newOpList = new list<Operation__c>();
            list<Operation__c> updateOpList =new list<Operation__c>();
            
            newOpList = [Select id,isBulkCreated__c from Operation__c where id IN : scope];
            
            for(Operation__c opList: newOpList){
                opList.isBulkCreated__c = true;
                updateOpList.add(opList);
            }
            update updateOpList;
            system.debug('--updateOpList--'+updateOpList);
            
            System.debug('---Scope--'+ Scope);
            dt = system.now();
            todayDate = date.newInstance(dt.year(), dt.month(), dt.day());
            for(Operation__c scheduledoperation : scope){
                
                Lead newLead = new Lead();
                Integer size=userIDs.size();
                boolean flag=false;
                
                for(String tempId:userIDs){
                    tempSize=tempSize+1;
                    if(userIDs.size()==1){
                        tempSize=0;
                    }
                    system.debug('--tempSize--'+tempSize);
                    if(userInLoopID==tempId){
                        newLead.User__c = userIDs.get(tempSize);
                        newLead.OwnerID = userIDs.get(tempSize);
                        userInLoopID = userIDs.get(tempSize);
                        if(tempSize==userIDs.size()-1){
                            maxSize=1;
                            system.debug('-maxSize-'+maxSize);
                        }
                        system.debug('-tempSize-'+tempSize);
                        tempSize=0;
                        flag=true;
                        break;
                    }
                }
                if(flag==false){
                        newLead.User__c = userIDs.get(0);
                        newLead.OwnerID = userIDs.get(0);
                        userInLoopID=userIDs.get(0);
                        tempSize=0;
                        maxSize=0;
                        system.debug('-userInLoopID in else if-'+userInLoopID);
                }
                
                if(maxSize==1){
                    userInLoopID=null;
                    system.debug('-userInLoopID-'+userInLoopID);
                }
                
                newLead.Salutation = scheduledoperation.Contact_Salutation__c;
                newLead.CCEmail__c=scheduledoperation.ContactCCEmail__c;
                newLead.LastName = scheduledoperation.Contact_LastName__c;
                newLead.FirstName = scheduledoperation.Contact_FirstName__c;
                newLead.Contact_Name__c = scheduledoperation.Contact_Name__c;
                newLead.Email = scheduledoperation.Contact_Email__c;
                newLead.Phone = scheduledoperation.Phone_Number__c;
                newLead.Enquiry_For__c = newLeadEnquiryFor;
                newLead.Created_Through__c = 'BDE';
                newLead.WorkFlowNumber__c = 1;
                newLead.CompliancePage__c = true;
                newLead.City = scheduledoperation.City__c;
                newLead.ROC_Name__c = scheduledoperation.ROC_Name__c;
                newLead.Incorporation_Date__c = scheduledoperation.Incorporation_Date__c;
                newLead.Auth_Capital__c = scheduledoperation.Auth_Capital__c;
                newLead.Paid_up_Capital__c = scheduledoperation.Paid_Up_Capital__c;
                newLead.BMCID__c = scheduledoperation.Name;
                newLead.Operation_owner__c = scheduledoperation.Owner_Name__c;
                newLead.Operations_Created_Date__c = scheduledoperation.createdDate;
                newLead.Company = scheduledoperation.New_Company_Name__c +' '+scheduledoperation.Company_Extention__c;
                newLead.BDE_Name__c = scheduledoperation.BDE_Name__c;
                newLead.isBulkcreated__c = true;
                newLeadList.add(newLead);
                
          }
    
    
        Database.SaveResult[] srList = Database.insert(newLeadList,false);
        for(Database.SaveResult sr : srList){
            if(sr.isSuccess()){
                system.debug('Successfully inserted Transaction. Transaction ID: ' + sr.getID());
            }
            else{
                for(Database.Error err : sr.getErrors()){
                    System.debug('The following error has occurred.');
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Transaction fields that affected this error: ' + err.getFields());

                }
            }
        }
        
        }catch(exception e){
            system.debug('--Exception--'+ e.getMessage());
        }  
         
    }
    
    global void finish(Database.BatchableContext BC){
        AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email
                                          from
                                          AsyncApexJob
                                          where
                                          Id =:BC.getJobId()];
         
         system.debug('--Batch Job contains--' + a);
         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
         String[] toAddresses = new String[] {'ankit.bobde@bmcgroup.in'};
         mail.setToAddresses(toAddresses);
         mail.setSubject('Bulk : Lead Creation Batch ' + a.Status);
         mail.setPlainTextBody
         ('The batch Apex job processed ' + a.TotalJobItems +
          ' batches with '+ a.NumberOfErrors + ' failures.');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        
     }
      
    

}

 
Hello,
I have a Text Area Field in  one of my custom Settings.
I want to pass some id's (say 10) into the TEXT AREA FIELD comma seperated and after that I want to get those id's into a single list so that I can iterate over it and Assign users using that ids.
Any help would be appreciated
I was gong through the Apex code and found out a code line;

Map<ID, List<Contacts>> mapCntList1 = new Map<ID, List<Contacts>>();

I was wondering this statement could have been written like this also;
Map<ID, Contacts> mapCntList2 = new Map<ID, Contacts>();
If the list declaration in "mapCntList1" is correct, can anyone tell when this should be used and when "mapCntList2" should be used?

Thanks
  • August 12, 2015
  • Like
  • 0
trigger TriggerAccountContacts on Account (after insert) {
list<contact> cons=new list<contact>();
    for(account a:trigger.new){
        contact c=new contact();
        c.lastname=a.name;
        c.Phone=a.phone;
        c.Description=a.description;
        c.AccountId=a.id; //what is accountid here is it record id of account object
        cons.add(c);
    }
    insert cons;
}