• pooja kesharwani
  • NEWBIE
  • 20 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi,

I am trying to update an Account record after insert. Below is my code:
 
trigger Trigger2 on Account (after insert, after update) {

    List<Account> acc= new List<Account>();
    for(Account a:trigger.new){
        a.Industry='Chemicals'; 
        acc.add(a);
}
    update acc;
}

When I am trying to save the record, it is giving me the error:

Trigger2: execution of AfterInsert caused by: System.FinalException: Record is read-only Trigger.Trigger2: line 5, column 1
​​​​​​​
I have two objects, job and employee. I tried to relate them with Master Detail but I am getting the below error:

You cannot create a new Master-Detail relationship on an existing custom object if records already exist. You must first create a Lookup relationship, populate the lookup field with data in all records, and then change the relationship type to Master-Detail.

Kindly help me here.