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

Update the field on the same object for after Insert event Trigger
Hi all,
There is one object let say Account. In Account I have 3 fields, Amount1, Amount2,Amount3. Now when I enter value in Amount1 at the time of creation of account record. Account2 field value get updated by (Amount1+10), that I am doing by before Insert event.
Now I want to update Amount3 field of same record let say by Amount2+40, so for this case I have to go by after insert event. I am doing the same by after insert event but it is throughing an error 'Feild is read only'.
There is one object let say Account. In Account I have 3 fields, Amount1, Amount2,Amount3. Now when I enter value in Amount1 at the time of creation of account record. Account2 field value get updated by (Amount1+10), that I am doing by before Insert event.
Now I want to update Amount3 field of same record let say by Amount2+40, so for this case I have to go by after insert event. I am doing the same by after insert event but it is throughing an error 'Feild is read only'.
You cannot change Trigger.new value on After event. Don't go for after insert, you can achieve in before insert trigger.
If user won't change amount 2 and amount 3 field values, then go for formula field. Please find the below sample trigger code,
All Answers
You cannot change Trigger.new value on After event. Don't go for after insert, you can achieve in before insert trigger.
If user won't change amount 2 and amount 3 field values, then go for formula field. Please find the below sample trigger code,
amount2 = amount1+10;
amount3 = amount2+10;
You can achieve this by two ways:
Create formula fields for amount2 and amount3(Preferred) or
Set Amount3 = Amount2+40 is nothing but
(Amount1+10)+40