Delete the demo/sample data from the trial phase out of your ORG

Once your ORG is active and you are working with your own data, you can delete all of the Propertybase demo data with just a few clicks!

Open the Developer Console:

In the "Debug" menu select "Open Execute Anonymous Windows":

Copy this code here and paste it to the new text box. Then press "Execute":

Organization org = [SELECT CreatedDate FROM Organization];
Datetime creationDateMin = org.CreatedDate;
Datetime creationDateMax = org.CreatedDate.addMinutes(2);

List<Contact> trialContacts = [Select id from contact where CreatedDate >= :creationDateMin AND CreatedDate < :creationDateMax];
delete [Select Id from pba__ActionPlan__c where pba__Contact__c in :trialContacts];
delete [Select Id from pba__DripCampaign__c where pba__Contact__c in :trialContacts];

for (SObjectType t : Schema.getGlobalDescribe().values()) {
String objName = t.getDescribe().getName();
  if (t == pba__Request__c.SObjectType
    || t == pba__Listing__c.SObjectType
    || t == pba__Property__c.SObjectType
    || t == pba__Offer__c.SObjectType
    || t == pba__Closing__c.SObjectType
    || t == Contact.SObjectType
    || t == Account.SObjectType
    || t == pba__Transaction__c.SObjectType
  ) {
    List<SObject> sObjs = Database.query('Select Id from ' + objName + ' Where CreatedDate >= :creationDateMin AND CreatedDate < :creationDateMax');
    delete sObjs;

You can find the deleted records in the recycle bin.

Powered by Zendesk