• Dev Aggarwal
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I have a custom field 'number_of_contact__c' in Account. I am trying to set the value of this custom field to zero before deleting the record.
I am getting an error at line ' loopAccount.number_of_contact__c = 0;'.
 
trigger RemoveNumberofcontact on Account (after undelete, before delete) 
if (Trigger.isDelete == true)
{	List <Account> ListAccount = new List<Account>(Trigger.old);
 
	for (Account LoopAccount : ListAccount)    
    {
        loopAccount.number_of_contact__c = 0;
    }
 update(ListAccount);
}
  
}

Thanks
I have a custom field 'number_of_contact__c' in Account. I am trying to set the value of this custom field to zero before deleting the record.
I am getting an error at line ' loopAccount.number_of_contact__c = 0;'.
 
trigger RemoveNumberofcontact on Account (after undelete, before delete) 
if (Trigger.isDelete == true)
{	List <Account> ListAccount = new List<Account>(Trigger.old);
 
	for (Account LoopAccount : ListAccount)    
    {
        loopAccount.number_of_contact__c = 0;
    }
 update(ListAccount);
}
  
}

Thanks