Skip to main content
included the closing bracket in highlighted code
Source Link

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

    trigger updateaccounting on Service__c (before insert,before update) {

    string custclass;
    string prodclass;
    string acccustclass;
    string accprodclass;
    string strServiceId;


    List<Service__c>lstservices = new List<Service__c>();
    List<Service__c> lstservicesUpdate = new List<Service__c>();
    List<Accounting__c> lstaccounting = new List<Accounting__c>();
    List<Service__c>lstservices1 = new List<Service__c>();
    lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

    system.debug('lstservices1 >>>>>>>>>'+lstservices1);
    for(Service__c service : lstservices1 ){
        strServiceId=service.id;
        custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
        prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
        system.debug('product classification values>>>>>'+prodclass+custclass );

        lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];


        for(Accounting__c accounting : lstaccounting ){

            system.debug('Accounting values>>>'+accounting);
            acccustclass = accounting.Rfleet_Customer_Tax__c;
            system.debug('accountcustomerclassfication values>>>>'+acccustclass);
            accprodclass = accounting.Rfleet_Product_Tax__c ;
            system.debug('accountproductclassfication values>>>'+accprodclass);

            if(acccustclass == custclass && accprodclass == prodclass){

                system.debug('>>>>>>>>>inside if>>');
                service.Rfleet_Accounting__c =accounting.id;
                service.id=strServiceId;

                system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
                system.debug('>>>>>>>>>'+accounting .id);
                lstservicesUpdate.add(service);

            }
        }

    }
    update lstservicesUpdate;
}

}

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

trigger updateaccounting on Service__c (before insert,before update) {

string custclass;
string prodclass;
string acccustclass;
string accprodclass;
string strServiceId;


List<Service__c>lstservices = new List<Service__c>();
List<Service__c> lstservicesUpdate = new List<Service__c>();
List<Accounting__c> lstaccounting = new List<Accounting__c>();
List<Service__c>lstservices1 = new List<Service__c>();
lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

system.debug('lstservices1 >>>>>>>>>'+lstservices1);
for(Service__c service : lstservices1 ){
    strServiceId=service.id;
    custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
    prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
    system.debug('product classification values>>>>>'+prodclass+custclass );

    lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];


    for(Accounting__c accounting : lstaccounting ){

        system.debug('Accounting values>>>'+accounting);
        acccustclass = accounting.Rfleet_Customer_Tax__c;
        system.debug('accountcustomerclassfication values>>>>'+acccustclass);
        accprodclass = accounting.Rfleet_Product_Tax__c ;
        system.debug('accountproductclassfication values>>>'+accprodclass);

        if(acccustclass == custclass && accprodclass == prodclass){

            system.debug('>>>>>>>>>inside if>>');
            service.Rfleet_Accounting__c =accounting.id;
            service.id=strServiceId;

            system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
            system.debug('>>>>>>>>>'+accounting .id);
            lstservicesUpdate.add(service);

        }
    }

}
update lstservicesUpdate;

}

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

    trigger updateaccounting on Service__c (before insert,before update) {

    string custclass;
    string prodclass;
    string acccustclass;
    string accprodclass;
    string strServiceId;


    List<Service__c>lstservices = new List<Service__c>();
    List<Service__c> lstservicesUpdate = new List<Service__c>();
    List<Accounting__c> lstaccounting = new List<Accounting__c>();
    List<Service__c>lstservices1 = new List<Service__c>();
    lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

    system.debug('lstservices1 >>>>>>>>>'+lstservices1);
    for(Service__c service : lstservices1 ){
        strServiceId=service.id;
        custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
        prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
        system.debug('product classification values>>>>>'+prodclass+custclass );

        lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];


        for(Accounting__c accounting : lstaccounting ){

            system.debug('Accounting values>>>'+accounting);
            acccustclass = accounting.Rfleet_Customer_Tax__c;
            system.debug('accountcustomerclassfication values>>>>'+acccustclass);
            accprodclass = accounting.Rfleet_Product_Tax__c ;
            system.debug('accountproductclassfication values>>>'+accprodclass);

            if(acccustclass == custclass && accprodclass == prodclass){

                system.debug('>>>>>>>>>inside if>>');
                service.Rfleet_Accounting__c =accounting.id;
                service.id=strServiceId;

                system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
                system.debug('>>>>>>>>>'+accounting .id);
                lstservicesUpdate.add(service);

            }
        }

    }
    update lstservicesUpdate;
}

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

trigger code:
 trigger updateaccounting on Service__c (before insert,before update) {

string custclass;
string prodclass;
string acccustclass;
string accprodclass;
string strServiceId;


List<Service__c>lstservices = new List<Service__c>();
List<Service__c> lstservicesUpdate = new List<Service__c>();
   List<Accounting__c> lstaccounting = new List<Accounting__c>();
    List<Service__c>lstservices1 = new List<Service__c>();
    lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

    system.debug('lstservices1 >>>>>>>>>'+lstservices1);
    for(Service__c service : lstservices1 ){
    strServiceId=service.id;
    custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
    prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
    system.debug('product classification values>>>>>'+prodclass+custclass );
    
    lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];
    
    
         for(Accounting__c accounting : lstaccounting ){
       
        system.debug('Accounting values>>>'+accounting);
        acccustclass = accounting.Rfleet_Customer_Tax__c;
        system.debug('accountcustomerclassfication values>>>>'+acccustclass);
        accprodclass = accounting.Rfleet_Product_Tax__c ;
        system.debug('accountproductclassfication values>>>'+accprodclass);
        
        if(acccustclass == custclass && accprodclass == prodclass){
     
    
         system.debug('>>>>>>>>>inside if>>');
            service.Rfleet_Accounting__c =accounting.id;
            service.id=strServiceId;
            
            system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
            system.debug('>>>>>>>>>'+accounting .id);
            lstservicesUpdate.add(service);
        
        }
    }
    
    }
update lstservicesUpdate;
}

}

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

trigger code:
 trigger updateaccounting on Service__c (before insert,before update) {

string custclass;
string prodclass;
string acccustclass;
string accprodclass;
string strServiceId;


List<Service__c>lstservices = new List<Service__c>();
List<Service__c> lstservicesUpdate = new List<Service__c>();
   List<Accounting__c> lstaccounting = new List<Accounting__c>();
    List<Service__c>lstservices1 = new List<Service__c>();
    lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

    system.debug('lstservices1 >>>>>>>>>'+lstservices1);
    for(Service__c service : lstservices1 ){
strServiceId=service.id;
    custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
    prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
    system.debug('product classification values>>>>>'+prodclass+custclass );
    
    lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];
    
    
         for(Accounting__c accounting : lstaccounting ){
       
        system.debug('Accounting values>>>'+accounting);
        acccustclass = accounting.Rfleet_Customer_Tax__c;
        system.debug('accountcustomerclassfication values>>>>'+acccustclass);
        accprodclass = accounting.Rfleet_Product_Tax__c ;
        system.debug('accountproductclassfication values>>>'+accprodclass);
        
        if(acccustclass == custclass && accprodclass == prodclass){
        
         system.debug('>>>>>>>>>inside if>>');
            service.Rfleet_Accounting__c =accounting.id;
            service.id=strServiceId;
            
            system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
            system.debug('>>>>>>>>>'+accounting .id);
            lstservicesUpdate.add(service);
        
        }
    }
    
    }
update lstservicesUpdate;
}

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

trigger updateaccounting on Service__c (before insert,before update) {

string custclass;
string prodclass;
string acccustclass;
string accprodclass;
string strServiceId;


List<Service__c>lstservices = new List<Service__c>();
List<Service__c> lstservicesUpdate = new List<Service__c>();
List<Accounting__c> lstaccounting = new List<Accounting__c>();
List<Service__c>lstservices1 = new List<Service__c>();
lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

system.debug('lstservices1 >>>>>>>>>'+lstservices1);
for(Service__c service : lstservices1 ){
    strServiceId=service.id;
    custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
    prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
    system.debug('product classification values>>>>>'+prodclass+custclass );

    lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];


    for(Accounting__c accounting : lstaccounting ){

        system.debug('Accounting values>>>'+accounting);
        acccustclass = accounting.Rfleet_Customer_Tax__c;
        system.debug('accountcustomerclassfication values>>>>'+acccustclass);
        accprodclass = accounting.Rfleet_Product_Tax__c ;
        system.debug('accountproductclassfication values>>>'+accprodclass);

        if(acccustclass == custclass && accprodclass == prodclass){
 
            system.debug('>>>>>>>>>inside if>>');
            service.Rfleet_Accounting__c =accounting.id;
            service.id=strServiceId;

            system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
            system.debug('>>>>>>>>>'+accounting .id);
            lstservicesUpdate.add(service);

        }
    }

}
update lstservicesUpdate;

}

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?my

my error is Like::>>>>Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

Error:Apex trigger codeupdateaccounting caused an unexpected exception, contact your administrator: trigger updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on Service__crow 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (before insertid = a0G4E000000BTRK) is currently in trigger updateaccounting,before therefore it cannot recursively update) { itself: []: Trigger.updateaccounting: line 48, column 1

string custclass; string prodclass; string acccustclass; string accprodclass; string strServiceId;

List<Service__c>lstservices = new List<Service__c>(); List<Service__c> lstservicesUpdate = new List<Service__c>(); List<Accounting__c> lstaccounting = new List<Accounting__c>(); List<Service__c>lstservices1 = new List<Service__c>(); lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

trigger code:
 trigger updateaccounting on Service__c (before insert,before update) {

string custclass;
string prodclass;
string acccustclass;
string accprodclass;
string strServiceId;


List<Service__c>lstservices = new List<Service__c>();
List<Service__c> lstservicesUpdate = new List<Service__c>();
   List<Accounting__c> lstaccounting = new List<Accounting__c>();
    List<Service__c>lstservices1 = new List<Service__c>();
    lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

    system.debug('lstservices1 >>>>>>>>>'+lstservices1);
    for(Service__c service : lstservices1 ){

strServiceId=service.id; custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c; prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c; system.debug('product classification values>>>>>'+prodclass+custclass );

strServiceId=service.id;
    custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
    prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
    system.debug('product classification values>>>>>'+prodclass+custclass );
    
    lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];
    
    
         for(Accounting__c accounting : lstaccounting ){
       
        system.debug('Accounting values>>>'+accounting);
        acccustclass = accounting.Rfleet_Customer_Tax__c;
        system.debug('accountcustomerclassfication values>>>>'+acccustclass);
        accprodclass = accounting.Rfleet_Product_Tax__c ;
        system.debug('accountproductclassfication values>>>'+accprodclass);
        
        if(acccustclass == custclass && accprodclass == prodclass){
        
        system.debug('>>>>>>>>>inside if>>');
            service.Rfleet_Accounting__c =accounting.id;
            service.id=strServiceId;
            
            system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
            system.debug('>>>>>>>>>'+accounting .id);
            lstservicesUpdate.add(service);
        
        }
    }
    
    }
update lstservicesUpdate;
}

update lstservicesUpdate; }

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?my error is Like::>>>>Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

trigger code: trigger updateaccounting on Service__c (before insert,before update) {

string custclass; string prodclass; string acccustclass; string accprodclass; string strServiceId;

List<Service__c>lstservices = new List<Service__c>(); List<Service__c> lstservicesUpdate = new List<Service__c>(); List<Accounting__c> lstaccounting = new List<Accounting__c>(); List<Service__c>lstservices1 = new List<Service__c>(); lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

system.debug('lstservices1 >>>>>>>>>'+lstservices1);
for(Service__c service : lstservices1 ){

strServiceId=service.id; custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c; prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c; system.debug('product classification values>>>>>'+prodclass+custclass );

lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];


     for(Accounting__c accounting : lstaccounting ){
   
    system.debug('Accounting values>>>'+accounting);
    acccustclass = accounting.Rfleet_Customer_Tax__c;
    system.debug('accountcustomerclassfication values>>>>'+acccustclass);
    accprodclass = accounting.Rfleet_Product_Tax__c ;
    system.debug('accountproductclassfication values>>>'+accprodclass);
    
    if(acccustclass == custclass && accprodclass == prodclass){
    
    system.debug('>>>>>>>>>inside if>>');
        service.Rfleet_Accounting__c =accounting.id;
        service.id=strServiceId;
        
        system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
        system.debug('>>>>>>>>>'+accounting .id);
        lstservicesUpdate.add(service);
    
    }
}

}

update lstservicesUpdate; }

I have written the trigger on service object.but i got error,i know updating the record on same object.how to overcome this type of error ?

my error is Like::

Error:Apex trigger updateaccounting caused an unexpected exception, contact your administrator: updateaccounting: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4E000000BTRKUA4; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0G4E000000BTRK) is currently in trigger updateaccounting, therefore it cannot recursively update itself: []: Trigger.updateaccounting: line 48, column 1

trigger code:
 trigger updateaccounting on Service__c (before insert,before update) {

string custclass;
string prodclass;
string acccustclass;
string accprodclass;
string strServiceId;


List<Service__c>lstservices = new List<Service__c>();
List<Service__c> lstservicesUpdate = new List<Service__c>();
   List<Accounting__c> lstaccounting = new List<Accounting__c>();
    List<Service__c>lstservices1 = new List<Service__c>();
    lstservices1 = [select Car_set__r.Order__r.Account.Customer_VAT_type__c,CB_Services_Repository__r.Rfleet_Product_classification__c from Service__c where id IN :Trigger.new];

    system.debug('lstservices1 >>>>>>>>>'+lstservices1);
    for(Service__c service : lstservices1 ){
strServiceId=service.id;
    custclass = service.Car_set__r.Order__r.Account.Customer_VAT_type__c;
    prodclass =service.CB_Services_Repository__r.Rfleet_Product_classification__c;
    system.debug('product classification values>>>>>'+prodclass+custclass );
    
    lstaccounting = [select Rfleet_Customer_Tax__c,Rfleet_Product_Tax__c from Accounting__c];
    
    
         for(Accounting__c accounting : lstaccounting ){
       
        system.debug('Accounting values>>>'+accounting);
        acccustclass = accounting.Rfleet_Customer_Tax__c;
        system.debug('accountcustomerclassfication values>>>>'+acccustclass);
        accprodclass = accounting.Rfleet_Product_Tax__c ;
        system.debug('accountproductclassfication values>>>'+accprodclass);
        
        if(acccustclass == custclass && accprodclass == prodclass){
        
        system.debug('>>>>>>>>>inside if>>');
            service.Rfleet_Accounting__c =accounting.id;
            service.id=strServiceId;
            
            system.debug('>>>>>>>>>'+service.Rfleet_Accounting__c);
            system.debug('>>>>>>>>>'+accounting .id);
            lstservicesUpdate.add(service);
        
        }
    }
    
    }
update lstservicesUpdate;
}
Source Link
kiran
  • 39
  • 8
Loading