• Adinarayana Kesani
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Please help me in this: I have created a counter field in account and have written the code like this
trigger AccountUpdationCounter on Account (after update) {

for(Account acts:trigger.new){
if(Trigger.isUpdate){
acts.Counter__c=0;
acts.Counter__c=acts.Counter__c+1;
}
update acts;
}
}
Getting below error after updating from UI:Error:Apex trigger AccountUpdationCounter caused an unexpected exception, contact your administrator: AccountUpdationCounter: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.AccountUpdationCounter: line 4, column 1