You need to sign in to do that
Don't have an account?
ss123
purge code not working in production but it is working in Full sandbox
public class DeleteContactWithNoCase {
// Intialization Variables
public contact con{get;set;}
public DateTime startDate{get;set;}
public DateTime EndDate{get;set;}
public string message{get;set;}
//Setting Up Constructor
public DeleteContactWithNoCase(ApexPages.StandardController controller) {
con = new contact(lastname='temp');}
public DeleteContactWithNoCase(){ EndDate=DateTime.now(); }
// This Method will Delete the Contacts which do not have any cases before start Date
public void DeleteContact(){
integer RecCount;
integer i;
RecCount=[Select count() from Contact where AccountId = '0017000000qz98bAAA' AND id not in (select ContactId from Case) limit 10000];
List<Contact> DeleteList = New List<Contact>();
for (i=1 ; i<=RecCount ; i=i+10000)
{
DeleteList = [SELECT Id FROM Contact WHERE CreatedDate <=:startDate AND AccountId = '0017000000qz98bAAA' AND id not in (select ContactId from Case) LIMIT 10000];
}
if(DeleteList.size()>0)
{
Delete DeleteList ;
message=DeleteList.size()+' Contacts have been successfully Deleted ';
}
else
{
message ='0 Records Found Please select some other date';
}
}
}
bouscal
You've hard coded the account ID '0017000000qz98bAAA', is it the same ID in both production and in your sandbox? You'd be better off retreiving the ID with a soql query.