• John Petrella
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2
    Replies
trigger CustomStatusChanged on Class__c (before update) {

    for(Class__c cls : trigger.new){
        if(cls.Custom_Status__c == 'Reset'){
            delete [Select Name from Student__c where Class_object__c in :trigger.new];
        }
    }
}

I have written this code but got self reference error

We have two custom Object Student and College.
I have one custom field in Student fee
And in Parent Total Amount
Whenever student joined to college Total Amount will be update using trigger
trigger CustomStatusChanged on Class__c (before update) {

    for(Class__c cls : trigger.new){
        if(cls.Custom_Status__c == 'Reset'){
            delete [Select Name from Student__c where Class_object__c in :trigger.new];
        }
    }
}

I have written this code but got self reference error