You need to sign in to do that
Don't have an account?

APEX Trigger Simple Field Update (Using a formula field)
Hello all,
I am trying to create a trigger that sets a Currency Field in the Object, to the result of what a formula was. The issue is that when i do this, it says
Error:Apex trigger UpdatePriceValue caused an unexpected exception, contact your administrator: UpdatePriceValue: execution of AfterUpdate caused by: System.Exception: Record is read-only: Trigger.UpdatePriceValue: line 4, column 3
Any way around this? I have the code below:
trigger UpdatePriceValue on Services_Selection__c (after insert, after update)
{
for (Services_Selection__c SS : Trigger.new)
{
SS.Price_Value__c = SS.Price_Formula__c;
}
}
Thanks in advance, to anyone who can help resolve this small issue.
Change to a before trigger instead of after. Based on what you have displayed, no reason why you couldn't.