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
SFDC BeginerSFDC Beginer 

Runtime Exception in trigger

Hi everyone, this is the task :  
// Populate contact description with modified user name when user updates contact.
trigger Contact_Before_Update on Contact (before update)
{     for(   Contact  
       {    c.Description='Contact update is successed by'+userInfo.getUserName();  
} }
// actully in for loop when I use Trigger.old, am getting run time erro. we can use Trigger.old right becaz before update we alaredy had the existing record right?  Could anyone please explain so confused. when I write its working fine. why cant we use Trigger.old here?
You are trying to update old value through Trigger.old, thats why the error is.
 Trigger.old is always read only. you can not set read only values in before update,
Try to update new value instead of Trigger.old
refer  :http://

Kindly let us know if it helps you, & close this query by selecting best answer if you got your solution, so this will helps other in future
If you find a post helpful and it answers your question, please mark it as an "Best Answer"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.