function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LAMCORPLAMCORP 

Trigger to create a copy record (similar to clone - Not handling bulk)

Hi all,

 

I have written a trigger that is intended to create a record of the same object when certain fields are populated. Like a clone with different fields populated as required. 

 

The triggers works fine and clones when I update one record. When I try to update more than one (EG 10) in one time it just brings back either one clone or 2 of the same clone. 

 

Puzzling... Any one able to see what I am doing wrong?

 

Appreciate your time in advance:)

 

trigger cloneElecAMsignOff on Electricity_Meter__c (before update,after update) {

     List<Electricity_Meter__c> myList = new List<Electricity_Meter__c>();
      

     for(Electricity_Meter__c a: trigger.new) {

        // insert Elec meter if Deal Done
        if (
        a.Account_Manager_Sign_Off_Date_Time__c != Null &&
        a.Lam_Clone_Date_Time_Stamp__c == Null && (
        a.Deal_Done_Not__c == 'Deal Done (Existing client / Existing meter)' ||
        a.Deal_Done_Not__c == 'Deal Done (New Meter, New Client)' || 
        a.Deal_Done_Not__c == 'Deal Done (New Meter, Exisiting Client)')) {
        
        Electricity_Meter__c b = new Electricity_Meter__c();                
        b.Name = a.Name; 
        b.Site_name__c = a.Site_name__c;
        b.Contract_arranged_under_the_name_of__c = a.Winning_Contract_Arranged_Under_Name_of__c;
        b.Account__c = a.Account__c; 
        b.Linked_Basket__c = a.Linked_Basket__c;
        b.Linked_Monitor_Line__c = a.Linked_Monitor_Line__c;
        b.Current_Supplier__c = a.Winning_Supplier__c;
        b.Previous_Supplier__c = a.Current_Supplier__c;
        b.Meter_Status__c = '(2) Active (Not yet live)';
        b.COT_Disc_Deenerg_Date__c = a.COT_Disc_Deenerg_Date__c;       
        b.Auto_Manual_Term__c = a.Auto_Manual_Term__c;
              
        b.Linked_Affiliate_1__c = a.Linked_Affiliate_1__c;    
        b.Aff_1_Profit_Split__c = a.Aff_1_Profit_Split__c;
        b.Linked_Affiliate_2__c = a.Linked_Affiliate_2__c;    
        b.Aff_2_Profit_Split__c = a.Aff_2_Profit_Split__c;        
        b.Linked_Affiliate_3__c = a.Linked_Affiliate_3__c;    
        b.Aff_3_Profit_Split__c = a.Aff_3_Profit_Split__c;
        
        b.Site_Address_New__c = a.Site_Address_New__c;
        b.Site_Postcode__c = a.Site_Postcode__c;
        b.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = a.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c;
        b.Billing_Address_New__c = a.Billing_Address_New__c;
        b.Billing_Postcode__c = a.Billing_Postcode__c;
        b.Number_of_employees__c = a.Number_of_employees__c;
        b.Annual_turnover_Euros__c = a.Annual_turnover_Euros__c;
        
        b.Profile_Class__c = a.Profile_Class__c;
        b.MTC_LLF__c = a.MTC_LLF__c;
        b.Meter_Details__c = a.Meter_Details__c; 
        b.MOP_CED__c = a.MOP_CED__c;
        b.Voltage_HV_LV_LVS__c = a.Voltage_HV_LV_LVS__c;
        
        b.Contract_start_date__c = a.Winning_Contract_Start_Date__c;
        b.Contract_expiry__c = a.Winning_Contract_End_Date__c;
        b.Payment_Method__c = a.Payment_Method__c;
        b.DD_Type__c = a.DD_Type__c;
        b.VAT__c = a.VAT__c;
        b.Monthly_Quarterly_Billing__c = a.Monthly_Quarterly_Billing__c;
        b.Copy_of_the_bills__c = a.Copy_of_the_bills__c;
        b.AQ__c = a.Winning_Supply_AQ__c;
        b.Total_KVA__c = a.Total_KVA__c; 
        b.Commission_p__c = a.Winning_Commision_p_kwh__c;
        b.Commission_per_year__c = a.Winning_Commission_year__c;
        b.Commission_Percent__c = a.Winning_Commission_Contract__c;  
        myList.add(b);  
        
        }


               
        // insert Elec meter if Deal Not Done
        else if (a.Account_Manager_Sign_Off_Date_Time__c != Null && 
        a.Lam_Clone_Date_Time_Stamp__c == Null && (
        a.Deal_Done_Not__c == 'Deal not done / Not responding - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Not responding - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Went direct with supplier - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Went direct with supplier - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Went with another consultant - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Went with another consultant - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Meter removed - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Meter removed - Client lost')) {
        
        Electricity_Meter__c c = new Electricity_Meter__c();                
        c.Name = a.Name; 
        c.Site_name__c = a.Site_name__c;
        c.Contract_arranged_under_the_name_of__c = a.Winning_Contract_Arranged_Under_Name_of__c; 
        c.Account__c = a.Account__c; 
        c.Linked_Basket__c = a.Linked_Basket__c;
        c.Linked_Monitor_Line__c = a.Linked_Monitor_Line__c;
        c.Current_Supplier__c = a.Winning_Supplier__c;
        c.Previous_Supplier__c = a.Current_Supplier__c;
        c.Meter_Status__c = '(5) Active (Not with Maxim Eyes)';
        c.COT_Disc_Deenerg_Date__c = a.COT_Disc_Deenerg_Date__c;        
        c.Auto_Manual_Term__c = a.Auto_Manual_Term__c;
              
        c.Linked_Affiliate_1__c = a.Linked_Affiliate_1__c;    
        c.Aff_1_Profit_Split__c = a.Aff_1_Profit_Split__c;
        c.Linked_Affiliate_2__c = a.Linked_Affiliate_2__c;    
        c.Aff_2_Profit_Split__c = a.Aff_2_Profit_Split__c;        
        c.Linked_Affiliate_3__c = a.Linked_Affiliate_3__c;    
        c.Aff_3_Profit_Split__c = a.Aff_3_Profit_Split__c;
        
        c.Site_Address_New__c = a.Site_Address_New__c;
        c.Site_Postcode__c = a.Site_Postcode__c;
        c.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = a.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c;
        c.Billing_Address_New__c = a.Billing_Address_New__c;
        c.Billing_Postcode__c = a.Billing_Postcode__c;
        c.Number_of_employees__c = a.Number_of_employees__c;
        c.Annual_turnover_Euros__c = a.Annual_turnover_Euros__c;
        
        c.Profile_Class__c = a.Profile_Class__c;
        c.MTC_LLF__c = a.MTC_LLF__c;
        c.Meter_Details__c = a.Meter_Details__c; 
        c.MOP_CED__c = a.MOP_CED__c;
        c.Voltage_HV_LV_LVS__c = a.Voltage_HV_LV_LVS__c;
        
        c.Contract_start_date__c = a.Winning_Contract_Start_Date__c;
        c.Contract_expiry__c = a.Winning_Contract_End_Date__c;
        c.Payment_Method__c = a.Payment_Method__c;
        c.DD_Type__c = a.DD_Type__c;
        c.VAT__c = a.VAT__c;
        c.Monthly_Quarterly_Billing__c = a.Monthly_Quarterly_Billing__c;
        c.Copy_of_the_bills__c = a.Copy_of_the_bills__c;
        c.AQ__c = a.Winning_Supply_AQ__c;
        c.Total_KVA__c = a.Total_KVA__c; 
        c.Commission_p__c = a.Winning_Commision_p_kwh__c;
        c.Commission_per_year__c = a.Winning_Commission_year__c;
        c.Commission_Percent__c = a.Winning_Commission_Contract__c;
        myList.add(c);           
        
        }

         
    try {
        insert myList; 
    } catch (system.Dmlexception e) {
        system.debug (e);   
        
    }
        
    }
        
        
}
Shailesh DeshpandeShailesh Deshpande
You have placed the DML inside the for loop


Other than that I dont see anything wrong with the trigger.
LAMCORPLAMCORP

Hi Shailesh,

 

Thanks for the reply. 

 

Any chance that you could rework the code so that the DML would not sit inside the FOR Loop? Just so I could try. 

 

Shailesh DeshpandeShailesh Deshpande
Just remove the entire try catch block and place it before the last curly brace.
LAMCORPLAMCORP

Fantastic. One Step closer. 

 

Now all the records are being cloned but just 2 copies. 

 

Looking into recursive now. 

 

Thanks

LAMCORPLAMCORP

Hi,

 

I removed the "atfer update" call and now is working perfectly. Been trying to write the test class but getting 7%!!!!

 

Can anyone see why?

 

rigger cloneElecAMsignOff on Electricity_Meter__c (before update) {


     List<Electricity_Meter__c> myList = new List<Electricity_Meter__c>();
      

     for(Electricity_Meter__c a: trigger.new) {

        // insert Elec meter if Deal Done
        if (
        a.Account_Manager_Sign_Off_Date_Time__c != Null &&
        a.Lam_Clone_Date_Time_Stamp__c == Null && (
        a.Deal_Done_Not__c == 'Deal Done (Existing client / Existing meter)' ||
        a.Deal_Done_Not__c == 'Deal Done (New Meter, New Client)' || 
        a.Deal_Done_Not__c == 'Deal Done (New Meter, Exisiting Client)')) {
        
        Electricity_Meter__c b = new Electricity_Meter__c();                
        b.Name = a.Name; 
        b.Site_name__c = a.Site_name__c;
        b.Contract_arranged_under_the_name_of__c = a.Winning_Contract_Arranged_Under_Name_of__c;
        b.Account__c = a.Account__c; 
        b.Linked_Basket__c = a.Linked_Basket__c;
        b.Linked_Monitor_Line__c = a.Linked_Monitor_Line__c;
        b.Current_Supplier__c = a.Winning_Supplier__c;
        b.Previous_Supplier__c = a.Current_Supplier__c;
        b.Meter_Status__c = '(2) Active (Not yet live)';
        b.COT_Disc_Deenerg_Date__c = a.COT_Disc_Deenerg_Date__c;       
        b.Auto_Manual_Term__c = a.Auto_Manual_Term__c;
              
        b.Linked_Affiliate_1__c = a.Linked_Affiliate_1__c;    
        b.Aff_1_Profit_Split__c = a.Aff_1_Profit_Split__c;
        b.Linked_Affiliate_2__c = a.Linked_Affiliate_2__c;    
        b.Aff_2_Profit_Split__c = a.Aff_2_Profit_Split__c;        
        b.Linked_Affiliate_3__c = a.Linked_Affiliate_3__c;    
        b.Aff_3_Profit_Split__c = a.Aff_3_Profit_Split__c;
        
        b.Site_Address_New__c = a.Site_Address_New__c;
        b.Site_Postcode__c = a.Site_Postcode__c;
        b.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = a.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c;
        b.Billing_Address_New__c = a.Billing_Address_New__c;
        b.Billing_Postcode__c = a.Billing_Postcode__c;
        b.Number_of_employees__c = a.Number_of_employees__c;
        b.Annual_turnover_Euros__c = a.Annual_turnover_Euros__c;
        
        b.Profile_Class__c = a.Profile_Class__c;
        b.MTC_LLF__c = a.MTC_LLF__c;
        b.Meter_Details__c = a.Meter_Details__c; 
        b.MOP_CED__c = a.MOP_CED__c;
        b.Voltage_HV_LV_LVS__c = a.Voltage_HV_LV_LVS__c;
        
        b.Contract_start_date__c = a.Winning_Contract_Start_Date__c;
        b.Contract_expiry__c = a.Winning_Contract_End_Date__c;
        b.Payment_Method__c = a.Payment_Method__c;
        b.DD_Type__c = a.DD_Type__c;
        b.VAT__c = a.VAT__c;
        b.Monthly_Quarterly_Billing__c = a.Monthly_Quarterly_Billing__c;
        b.Copy_of_the_bills__c = a.Copy_of_the_bills__c;
        b.AQ__c = a.Winning_Supply_AQ__c;
        b.Total_KVA__c = a.Total_KVA__c; 
        b.Commission_p__c = a.Winning_Commision_p_kwh__c;
        b.Commission_per_year__c = a.Winning_Commission_year__c;
        b.Commission_Percent__c = a.Winning_Commission_Contract__c;  
        myList.add(b);  
        
        }


               
        // insert Elec meter if Deal Not Done
        else if (a.Account_Manager_Sign_Off_Date_Time__c != Null && 
        a.Lam_Clone_Date_Time_Stamp__c == Null && (
        a.Deal_Done_Not__c == 'Deal not done / Not responding - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Not responding - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Went direct with supplier - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Went direct with supplier - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Went with another consultant - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Went with another consultant - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Meter removed - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Meter removed - Client lost')) {
        
        Electricity_Meter__c c = new Electricity_Meter__c();                
        c.Name = a.Name; 
        c.Site_name__c = a.Site_name__c;
        c.Contract_arranged_under_the_name_of__c = a.Winning_Contract_Arranged_Under_Name_of__c; 
        c.Account__c = a.Account__c; 
        c.Linked_Basket__c = a.Linked_Basket__c;
        c.Linked_Monitor_Line__c = a.Linked_Monitor_Line__c;
        c.Current_Supplier__c = a.Winning_Supplier__c;
        c.Previous_Supplier__c = a.Current_Supplier__c;
        c.Meter_Status__c = '(5) Active (Not with ME)';
        c.COT_Disc_Deenerg_Date__c = a.COT_Disc_Deenerg_Date__c;        
        c.Auto_Manual_Term__c = a.Auto_Manual_Term__c;
              
        c.Linked_Affiliate_1__c = a.Linked_Affiliate_1__c;    
        c.Aff_1_Profit_Split__c = a.Aff_1_Profit_Split__c;
        c.Linked_Affiliate_2__c = a.Linked_Affiliate_2__c;    
        c.Aff_2_Profit_Split__c = a.Aff_2_Profit_Split__c;        
        c.Linked_Affiliate_3__c = a.Linked_Affiliate_3__c;    
        c.Aff_3_Profit_Split__c = a.Aff_3_Profit_Split__c;
        
        c.Site_Address_New__c = a.Site_Address_New__c;
        c.Site_Postcode__c = a.Site_Postcode__c;
        c.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = a.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c;
        c.Billing_Address_New__c = a.Billing_Address_New__c;
        c.Billing_Postcode__c = a.Billing_Postcode__c;
        c.Number_of_employees__c = a.Number_of_employees__c;
        c.Annual_turnover_Euros__c = a.Annual_turnover_Euros__c;
        
        c.Profile_Class__c = a.Profile_Class__c;
        c.MTC_LLF__c = a.MTC_LLF__c;
        c.Meter_Details__c = a.Meter_Details__c; 
        c.MOP_CED__c = a.MOP_CED__c;
        c.Voltage_HV_LV_LVS__c = a.Voltage_HV_LV_LVS__c;
        
        c.Contract_start_date__c = a.Winning_Contract_Start_Date__c;
        c.Contract_expiry__c = a.Winning_Contract_End_Date__c;
        c.Payment_Method__c = a.Payment_Method__c;
        c.DD_Type__c = a.DD_Type__c;
        c.VAT__c = a.VAT__c;
        c.Monthly_Quarterly_Billing__c = a.Monthly_Quarterly_Billing__c;
        c.Copy_of_the_bills__c = a.Copy_of_the_bills__c;
        c.AQ__c = a.Winning_Supply_AQ__c;
        c.Total_KVA__c = a.Total_KVA__c; 
        c.Commission_p__c = a.Winning_Commision_p_kwh__c;
        c.Commission_per_year__c = a.Winning_Commission_year__c;
        c.Commission_Percent__c = a.Winning_Commission_Contract__c;
        myList.add(c);           
        
        }

        //if (
        //a.Account_Manager_Sign_Off_Date_Time__c != Null &&
        //a.Lam_Clone_Date_Time_Stamp__c == Null ){
        //a.Lam_Clone_Date_Time_Stamp__c = dateTime.Now();
        //update myList; 
     
        //}         

        
    }
       
        try {
        insert myList; 
    } catch (system.Dmlexception e) {
        system.debug (e);      
    }
        
        
}

 

And the Test Class coming in next thread to large

 

 
LAMCORPLAMCORP

Test Class

 

@isTest
Private Class cloneElecAMsignOff{
Static testMethod void TestcloneElecAMsignOff(){

        Profile p = [select id from profile where name='Standard User'];
        
        User u = new User(alias = 'test123', email='test123@noemail.com',
        emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
        localesidkey='en_US', profileid = p.Id, country='United States',
        timezonesidkey='America/Los_Angeles', username='test123@noemail.com');
        insert u;
        
        Affiliate__c aff = new Affiliate__c(
        name = 'Test aff');
        insert aff;
        
        Affiliate__c aff2 = new Affiliate__c(
        name = 'Test aff2');
        insert aff2;

        Affiliate__c aff3 = new Affiliate__c(
        name = 'Test aff3');
        insert aff3;                
              
        Team_Dept__c teamDept = new Team_Dept__c(
        name = 'FF Sales');
        insert teamDept;
        
        // Insert a normal Account
        Account acct = new Account(
        Team_s_Dept_s__c = teamDept.Id,
        ME1__c = u.Id,
        name = 'Test Acct',
        industry = 'Finance',
        local_network_folder__c = 'M Drive',
        Account_Status__c = 'Live',
        Relationship_Status__c = 'Green [All Good]',
        Client_Potential__c = 'Diamond [More than 100k]',
        Linked_Affiliate_1__c=aff.Id,  
        Aff_1_Profit_Split__c =0);
        insert acct;
        
        // Insert a Basket Account
        Account baskAcct = new Account(
        Team_s_Dept_s__c = teamDept.Id,
        ME1__c = u.Id,
        name = 'No (Basket)',
        industry = 'Finance',
        local_network_folder__c = 'M Drive',
        Account_Status__c = 'Live',
        Relationship_Status__c ='Green [All Good]',
        Client_Potential__c = 'Diamond [More than 100k]',
        Linked_Affiliate_1__c=aff.Id,  
        Aff_1_Profit_Split__c =0);
        insert baskAcct;
        
        // Insert a Monitor Line
        Line_del__c monLine = new Line_del__c(
        Team_s_Dept_s_del__c = teamDept.Id,
        ME1__c = u.Id,
        name = 'Test Line',
        DTR3__c = System.Today(),
        Stage__c = 'Closed Off',
        Suggested_Stage__c = 'Closed Off',
        Division__c = 'Util-Eyes',
        Utility__c = 'Gas',
        Renewal_Acquisition__c = 'Renewal',
        Linked_Account__c = acct.Id);
        insert monLine;
        
        Electricity_Meter__c elecOrig = new Electricity_Meter__c(
        
        Name = 'TEST',
        Site_name__c = 'Test Site', 
        Contract_arranged_under_the_name_of__c = 'Test Contract Name',         
        Meter_Status__c = '(1) Active',
        Account__c = acct.Id,
        Linked_Basket__c  = baskAcct.Id,  
        Linked_Monitor_Line__c = monLine.Id,
        Current_Supplier__c = 'Gaz De France',
        Previous_Supplier__c = 'Gaz De France', 
        Deal_Done_Not__c = 'Deal Done (Existing Client / Existing Meter)',
        COT_Disc_Deenerg_Date__c = System.Today(),        
        Auto_Manual_Term__c = 'Single - Automatic Termination',
        Linked_Affiliate_1__c= aff.Id,          
        Aff_1_Profit_Split__c =0,
        Linked_Affiliate_2__c = aff2.Id,     
        Aff_2_Profit_Split__c =0,
        Linked_Affiliate_3__c = aff3.Id,    
        Aff_3_Profit_Split__c =0,  
        Site_Address_New__c = 'Test Road',
        Site_Postcode__c = 'SW1 1PP',
        Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = 'Sole Trader',
        Billing_Address_New__c = 'Test Lane',
        Billing_Postcode__c = 'SW1 1PR',
        Number_of_employees__c = 'n/a',
        Annual_turnover_Euros__c = 'n/a',
        Profile_Class__c = '00',
        MTC_LLF__c = '123345',
        Meter_Details__c = '12 1234 1234 123', 
        MOP_CED__c = System.Today()+1,
        Voltage_HV_LV_LVS__c = 'LV',
        Contract_expiry__c = System.Today()+50,
        Winning_Contract_start_date__c = System.Today()+100,
        Winning_Contract_end_date__c = System.Today()+200, 
        Payment_Method__c ='Single DD', 
        DD_Type__c = 'Fixed DD',
        VAT__c = '20%',
        Monthly_Quarterly_Billing__c = 'Quarterly',
        Copy_of_the_bills__c = 'Yes',
        Winning_Supply_AQ__c = 100000000,
        Total_KVA__c = 0.50,
        Winning_Commision_p_kwh__c = 0.3,
        Winning_Commission_year__c = Null,
        Winning_Commission_Contract__c = Null          
        );
        insert elecOrig;
        
        
     
        List<Electricity_Meter__c> myList = new List<Electricity_Meter__c>();
        for(Integer i=0;i<200;i++) {
        Electricity_Meter__c elec = new Electricity_Meter__c(
        
        Deal_Done_Not__c = elecOrig.Deal_Done_Not__c, 
        Meter_Status__c = '(2) Active (Not yet live)',
        Name = elecOrig.Name,
        Site_name__c = elecOrig.Site_name__c,
        Contract_arranged_under_the_name_of__c = elecOrig.Contract_arranged_under_the_name_of__c, 
        Account__c = elecOrig.Account__c,
        Linked_Basket__c = elecOrig.Linked_Basket__c,
        Linked_Monitor_Line__c = elecOrig.Linked_Monitor_Line__c,       
        Current_Supplier__c = elecOrig.Current_Supplier__c,
        Previous_Supplier__c = elecOrig.Previous_Supplier__c,
        COT_Disc_Deenerg_Date__c = elecOrig.COT_Disc_Deenerg_Date__c,        
        Auto_Manual_Term__c = elecOrig.Auto_Manual_Term__c,
        
        Linked_Affiliate_1__c = elecOrig.Linked_Affiliate_1__c,    
        Aff_1_Profit_Split__c = elecOrig.Aff_1_Profit_Split__c,
        Linked_Affiliate_2__c = elecOrig.Linked_Affiliate_2__c,     
        Aff_2_Profit_Split__c = elecOrig.Aff_2_Profit_Split__c,
        Linked_Affiliate_3__c = elecOrig.Linked_Affiliate_3__c,    
        Aff_3_Profit_Split__c = elecOrig.Aff_3_Profit_Split__c,
                
        Site_Address_New__c = elecOrig.Site_Address_New__c,
        Site_Postcode__c = elecOrig.Site_Postcode__c,
        Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = elecOrig.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c,
        Billing_Address_New__c = elecOrig.Billing_Address_New__c,
        Billing_Postcode__c = elecOrig.Billing_Postcode__c,
        Number_of_employees__c = elecOrig.Number_of_employees__c,
        Annual_turnover_Euros__c = elecOrig.Annual_turnover_Euros__c,
        Profile_Class__c = elecOrig.Profile_Class__c,
        MTC_LLF__c = elecOrig.MTC_LLF__c,
        Meter_Details__c = elecOrig.Meter_Details__c,
        MOP_CED__c = elecOrig.MOP_CED__c,
        Voltage_HV_LV_LVS__c = elecOrig.Voltage_HV_LV_LVS__c,       
        Contract_start_date__c = elecOrig.Winning_Contract_start_date__c,
        Contract_expiry__c = elecOrig.Winning_Contract_end_date__c,       
        Payment_Method__c = elecOrig.Payment_Method__c, 
        DD_Type__c = elecOrig.DD_Type__c,
        VAT__c = elecOrig.VAT__c,
        Monthly_Quarterly_Billing__c = elecOrig.Monthly_Quarterly_Billing__c,
        Copy_of_the_bills__c = elecOrig.Copy_of_the_bills__c,
        AQ__c = elecOrig.Winning_Supply_AQ__c,
        Total_KVA__c = elecOrig.Total_KVA__c,
        Commission_p__c = elecOrig.Winning_Commision_p_kwh__c,
        Commission_per_year__c = elecOrig.Winning_Commission_year__c,
        Commission_Percent__c = elecOrig.Winning_Commission_Contract__c
        );       
        myList.add(elec);
        }        
        

    Test.startTest();
    upsert myList;
    Test.stopTest();
      
    
    }   
}

Thomas Shelby 26Thomas Shelby 26
Our skilled electricians are capable at evaluating and resolving a wide range of electrical issues in both residential and business settings.
https://onegoodhandyman.co.uk/north-london/