Hi Adi, Please try this code and check all previous questions which you have the post. mark as solve which may help others.
Example: Delete all contacts belonging to Accounts Name FIELD having 'A' in them.
public class DeleteContact { public static List<Contact> delMethod(){ List<Contact> conList = new List<Contact>(); conList = [SELECT ID ,Account.Name FROM Contact WHERE Account.Name like '%A%'];
Hi Adi,
Please try this code and check all previous questions which you have the post.
mark as solve which may help others.
Example: Delete all contacts belonging to Accounts Name FIELD having 'A' in them.
public class DeleteContact {
public static List<Contact> delMethod(){
List<Contact> conList = new List<Contact>();
conList = [SELECT ID ,Account.Name FROM Contact
WHERE Account.Name like '%A%'];
if(conList.size()>0){
database.delete(conList,false);
}
return conList;
}
}
Please let me know if you have any query.
Please mark it as best Answer if you find it helpful.
Thank You
Please try this Query:
General Examlple
Object__c obj = [select Id from Object__c where Id = 'xxxxx'];
Database.delete(obj,false);
Example:
Account acc= [select Id from Account ];
Database.delete(acc,false);
Thanks
Akshay
Please try this code in Anonymous Window and if helpful then mark as solve which may help others.
Ex: To Delete Account Records.
List<Account> accountList =[Select id,Name from Account];
Database.delete(accountList ,false);
Thanks
Developer Forum