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
chokchok 

trigger syntax

HI,

I am new to apex and triggers when i write the below code its not firing trigger can any one please help me.



Trigger webaccount on Account (after insert) {
for(Account a: Trigger.new)
{
if(a.Website ==null){
a.Website = 'www.google.com';
}
else a.Website = 'froce.com';
}
}



Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger webaccount caused an unexpected exception, contact your administrator: webaccount: execution of AfterInsertcaused by: System.FinalException: Record is read-only: Trigger.webaccount: line 5, column 1

Best Answer chosen by Admin (Salesforce Developers) 
sebcossebcos

Hi,

the error message says record is read-only and this is the case for after insert triggers.

Please review the table here for some important considerations about triggers:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables_considerations.htm

All Answers

sebcossebcos

Hi,

the error message says record is read-only and this is the case for after insert triggers.

Please review the table here for some important considerations about triggers:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables_considerations.htm

This was selected as the best answer
chokchok

thank you for ur time

its helpful for me