Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I'm new to Apex code, got below error Error: Invalid Data. Review all error messages below to correct your data. Apex trigger PositionTrigger caused an unexpected exception, contact your administrator: PositionTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.PositionTrigger: line 4, column 1

trigger PositionTrigger on Position__c (after insert) {
  Position__c ThePosition =[0];
    update ThePosition;

please let me know the solution.

share|improve this question

marked as duplicate by ca_peterson, Samuel De Rycke, Boris Bachovski, LaceySnr Mar 5 '14 at 0:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

When you are doing an After trigger, is read only. If you want to make changes to it, then it is best to do it in a Before trigger.

Also, your trigger is not bulkified. If more than one record is updated at a time, then only the first one will be evaluated. See and search for other examples.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.