You need to sign in to do that
Don't have an account?

Recursive error in triger
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger VisitTriggers caused an unexpected exception, contact your administrator: VisitTriggers: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Cf0000007rjNsEAI; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0Cf0000007rjNs) is currently in trigger VisitTriggers, therefore it cannot recursively update itself: []: Class.VisitTriggerHandler.OrderRaisedVisitUpdate: line 255, column 1
for this code
Private void OrderRaisedVisitUpdate(Map<id,Visits__c> visitsMap)
{
Id visitid;
List<Visits__c> visit = visitsMap.values();
//public String visitId;
//visitId=ApexPages.currentPage().getParameters().get(VisitList);
//Visits__c visit=[select id,Order_Raised__c from Visits__c where id=:visitid];
Visits__c vt=[select id,Order_Raised__c from Visits__c where id =: visit[0].id ];
for(AggregateResult result :[select Visit__c,sum(Total_Amount__c) total from SFDC_Purchase_Order__c where Visit__c =:visit[0].id group by Visit__c]){
tot=Double.valueOf(result.get('total'));
}
vt.Order_Raised__c =tot;
update vt; // get error this update field
}
I have create two object for visit and SFDC_supplier_purchase_Order. when purchase order raised in SFDC_supplier_purchase_Order at that time get total amount and add into the visit field purchase order raised. When purchase order rasie, repeatley do this.
Review all error messages below to correct your data.
Apex trigger VisitTriggers caused an unexpected exception, contact your administrator: VisitTriggers: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Cf0000007rjNsEAI; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0Cf0000007rjNs) is currently in trigger VisitTriggers, therefore it cannot recursively update itself: []: Class.VisitTriggerHandler.OrderRaisedVisitUpdate: line 255, column 1
for this code
Private void OrderRaisedVisitUpdate(Map<id,Visits__c> visitsMap)
{
Id visitid;
List<Visits__c> visit = visitsMap.values();
//public String visitId;
//visitId=ApexPages.currentPage().getParameters().get(VisitList);
//Visits__c visit=[select id,Order_Raised__c from Visits__c where id=:visitid];
Visits__c vt=[select id,Order_Raised__c from Visits__c where id =: visit[0].id ];
for(AggregateResult result :[select Visit__c,sum(Total_Amount__c) total from SFDC_Purchase_Order__c where Visit__c =:visit[0].id group by Visit__c]){
tot=Double.valueOf(result.get('total'));
}
vt.Order_Raised__c =tot;
update vt; // get error this update field
}
I have create two object for visit and SFDC_supplier_purchase_Order. when purchase order raised in SFDC_supplier_purchase_Order at that time get total amount and add into the visit field purchase order raised. When purchase order rasie, repeatley do this.
Please remove update vt; statement from the end. I think it solves your problem.