You need to sign in to do that
Don't have an account?
shoba shoba
Trigger to update the checkbox field
Hi
My scenario is to update the checkbox field if the Address field in Account is update. After 30 second of the record saved, it should uncheck the checkbox field.
Can anyone help me out to solve this issue.
Trigger throwing an error "
execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001Q00000104rDvIAI; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001Q00000104rDv) is currently in trigger test, therefore it cannot recursively update itself: []: Trigger.test: line 15, column 1"
My scenario is to update the checkbox field if the Address field in Account is update. After 30 second of the record saved, it should uncheck the checkbox field.
Can anyone help me out to solve this issue.
Trigger throwing an error "
trigger test on Account (before update) { list<Account> a = new list<Account>(); Account acc = [select Id,checkboxForPopUp__c,BillingAddress,BillingCity,BillingCountry,BillingCountryCode,BillingPostalCode,BillingState,BillingStateCode,BillingStreet from Account where Id =:trigger.new]; if( (acc!=Null) && ((acc.BillingAddress != trigger.oldmap.get(acc.id).BillingAddress) || (acc.BillingCity != trigger.oldmap.get(acc.id).BillingCity) || (acc.BillingCountry != trigger.oldmap.get(acc.id).BillingCountry) || (acc.BillingStateCode != trigger.oldmap.get(acc.id).BillingStateCode) || (acc.BillingStreet != trigger.oldmap.get(acc.id).BillingStreet)) ) { acc.checkboxForPopUp__c = TRUE; a.add(acc); } update acc; }
execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001Q00000104rDvIAI; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001Q00000104rDv) is currently in trigger test, therefore it cannot recursively update itself: []: Trigger.test: line 15, column 1"
Please refer below mentioned code:
List<Account> acc=new List<Account>();
for(Account ac:trigger.new){
Account oldOpp = Trigger.oldMap.get(ac.ID);
if(ac.BillingAddress != oldopp.BillingAddress || ac.BillingCity != oldopp.BillingCity || ac.BillingCountry != oldopp.BillingCountry || ac.BillingPostalCode!= oldopp.BillingPostalCode || ac.BillingStreet != oldopp.BillingStreet){
ac.checkboxForPopUp__c =true;
}
}
}
Before Update Don't Use the "Update" Try this Trigger So help full for You