• shubham shrawankar
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi, I am learning SF developer. I created 100 records in Account object using SQL query. then im trying to delete all those records using SOQL query and for loop here is my code:
list<Account> newlist=new list<Account>();
newlist=[SELECT Id,Name FROM Account WHERE Name='test name'];
system.debug('list'+newlist);
list<Account> deletelist=new list<Account>();
for(Account a: newlist){
    a.Name='test name';
    deletelist.add(a);
}
system.debug('list'+deletelist);
delete deletelist;
but i am unable to delete. i know i can use work bench for this but i want to delete using SOQL here is the error im facing:
Line: 10, Column: 1
System.DmlException: Delete failed. First exception on row 0 with id 0016F00003O5AOEQA3; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, acountdeletetrigger: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object Class.accountdeleteclass.deletecheck: line 3, column 1 Trigger.acountdeletetrigger: line 3, column 1: []
please tell me whats wrong thanks