• Vipul-Goyal
  • 10 Points
  • Member since 2020
  • Salesforce Developer

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 4
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'];
list<Account> deletelist=new list<Account>();
for(Account a: newlist){
    a.Name='test name';
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
Hi all,

Delete records batch apex account ,contacts ,opportunity and cases in single batchclass
I am trying to develop something for our production Customer Community in a Developer org.  I need Customer Community licenses for testing.  How do I get them?



I do a monthly Upsert via bulk upload (Apex Data Loader) of records on custom object Subscriber__c.


What I want to do is once the upsert is complete, delete any records that were not created or updated during he bulk Upsert process.


Here is the trigger I have written - and I am aware this may be terrible or not even close to what I need :)


trigger DeleteSubs on Subscriber__c(after insert, after update) {
 List<Id> lstId = new List<Id>();
for(Subscriber__c sub: Trigger.old){
        List<Subscriber__c> nolongersubs = [Select Id from Subscriber__c where LastModifiedDate<TODAY];
        delete nolongersubs;

 When trying to insert a single record I am getting execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object:Trigger.DeleteSubs: line 4, column 1


Any help would be greatly appeciated.