You need to sign in to do that
Don't have an account?
Saumya Suman
Hii, I need help on below trigger. Whenever I save any data or update any data I get theseerror
trigger Trigger4 on Account (After update)
{
System.debug('Total number of records in Trigger' + Trigger.size);
for(account a : trigger.old)
{
System.debug('Account that got inserted is......' + a.name);
}
for(account b : trigger.new)
{
b.description = 'Updated by Trigger';
System.debug('Account that got inserted is......' + b.name);
}
}
Get Error on on updating any record-
Review all error messages below to correct your data.
Apex trigger Trigger4 caused an unexpected exception, contact your administrator: Trigger4: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.Trigger4: line 11, column 1
And whenever try to create any new record get below error-
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Trigger9 caused an unexpected exception, contact your administrator: Trigger9: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trigger4: execution of AfterUpdate caused by: System.FinalException: Record is read-only Trigger.Trigger4: line 11, column 1: []: Trigger.Trigger9: line 13, column 1
{
System.debug('Total number of records in Trigger' + Trigger.size);
for(account a : trigger.old)
{
System.debug('Account that got inserted is......' + a.name);
}
for(account b : trigger.new)
{
b.description = 'Updated by Trigger';
System.debug('Account that got inserted is......' + b.name);
}
}
Get Error on on updating any record-
Review all error messages below to correct your data.
Apex trigger Trigger4 caused an unexpected exception, contact your administrator: Trigger4: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.Trigger4: line 11, column 1
And whenever try to create any new record get below error-
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Trigger9 caused an unexpected exception, contact your administrator: Trigger9: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trigger4: execution of AfterUpdate caused by: System.FinalException: Record is read-only Trigger.Trigger4: line 11, column 1: []: Trigger.Trigger9: line 13, column 1
Shawn Reichner 29
Agree with Hermant, pleas eupdate your code to before update and you should be fine as the record when it is inserted or updated the record itself is locked to a sense until it has been fully committed to the database.