• Szymon
  • NEWBIE
  • 25 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
Trying to align labels on a VF page so they are consistent (e.g. on top of the input field) but struggling a lot. Any advise how to solve the below? Thanks!
VF screen
  • March 13, 2019
  • Like
  • 0
Hi, I'm trying to write a test class for the below:
global class EmptyDeletedRecords implements Database.Batchable<sObject>, Schedulable{   
    global EmptyDeletedRecords(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Deleted_record__c where CreatedDate <LAST_N_DAYS:5]);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        EmptyDeletedRecords deleteCS = new EmptyDeletedRecords();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}
But am not sure how to test the scope deletion:
@isTest
private class EmptyDeletedRecords_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
    Deleted_record__c deleted_record_Obj = new Deleted_record__c(Deleted_ID__c = '5001p00002O54P2AAJ', External_ID__c = 'null', Object_Type_From_Apex__c = 'Case_with_custom_object');
    Insert deleted_record_Obj; 
    test.stopTest();
  }
    
    static testMethod void testBatch(){
    SchedulableContext sc = null;
    EmptyDeletedRecords tsc = new EmptyDeletedRecords();
    tsc.execute(sc);
  }
}
Any advice how to test that? Thanks!

 
I need to access ALL data sets in a list custom setting rather than name a specific data set:
CustomSettingName__c mc = CustomSettingName__c.getValues(data_set_name);

Tried the below but then the query will return an error:
list <CustomSetting__c> mc = CustomSetting__c.getAll().values();

Database.getQueryLocator([select Id FROM Case WHERE Country__c LIKE :mc.Country_Code__c]);
ERROR: Variable does not exist: Country_Code__c

Can someone help me out please?
 
  • April 26, 2018
  • Like
  • 0
Hi, wonder if anyone could guide me in the right direction. Got the below class but the requirement has changed since and now I need to insert the id's of deleted records into a custom object for tracking purposes before they get deleted. any ideas? Thanks
 
global class BatchDeletion implements Database.Batchable<sObject>, Schedulable{   
    global BatchDeletion(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Case where Archived__c='true']);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        BatchDeletion deleteCS = new BatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}

 
  • March 22, 2018
  • Like
  • 0
Hi, I'm trying to write a test class for the below:
global class EmptyDeletedRecords implements Database.Batchable<sObject>, Schedulable{   
    global EmptyDeletedRecords(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Deleted_record__c where CreatedDate <LAST_N_DAYS:5]);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        EmptyDeletedRecords deleteCS = new EmptyDeletedRecords();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}
But am not sure how to test the scope deletion:
@isTest
private class EmptyDeletedRecords_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
    Deleted_record__c deleted_record_Obj = new Deleted_record__c(Deleted_ID__c = '5001p00002O54P2AAJ', External_ID__c = 'null', Object_Type_From_Apex__c = 'Case_with_custom_object');
    Insert deleted_record_Obj; 
    test.stopTest();
  }
    
    static testMethod void testBatch(){
    SchedulableContext sc = null;
    EmptyDeletedRecords tsc = new EmptyDeletedRecords();
    tsc.execute(sc);
  }
}
Any advice how to test that? Thanks!

 
I need to access ALL data sets in a list custom setting rather than name a specific data set:
CustomSettingName__c mc = CustomSettingName__c.getValues(data_set_name);

Tried the below but then the query will return an error:
list <CustomSetting__c> mc = CustomSetting__c.getAll().values();

Database.getQueryLocator([select Id FROM Case WHERE Country__c LIKE :mc.Country_Code__c]);
ERROR: Variable does not exist: Country_Code__c

Can someone help me out please?
 
  • April 26, 2018
  • Like
  • 0
Hi, wonder if anyone could guide me in the right direction. Got the below class but the requirement has changed since and now I need to insert the id's of deleted records into a custom object for tracking purposes before they get deleted. any ideas? Thanks
 
global class BatchDeletion implements Database.Batchable<sObject>, Schedulable{   
    global BatchDeletion(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Case where Archived__c='true']);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        BatchDeletion deleteCS = new BatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}

 
  • March 22, 2018
  • Like
  • 0