You need to sign in to do that
Don't have an account?
Chad Coffey
Help building a Test Class
I have an Apex Class that is deleting a large number of record based on a SOQL query that is entered. I am having a very hard time getting a TestClass Built. Any help would be greatly appreciated!
Batch Class:
global class TestBatch implements Database.Batchable<sObject>{
global final String Query;
global TestBatch(String q){
Query=q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
delete scope;
}
global void finish(Database.BatchableContext BC){
}
}
When I run the following script in the console, the records associated with the object are deleted.
String query = 'SELECT Id FROM jstcl__PlacementTeamMember__c';
Database.executeBatch(new TestBatch(query), 10000);
Batch Class:
global class TestBatch implements Database.Batchable<sObject>{
global final String Query;
global TestBatch(String q){
Query=q;
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
delete scope;
}
global void finish(Database.BatchableContext BC){
}
}
When I run the following script in the console, the records associated with the object are deleted.
String query = 'SELECT Id FROM jstcl__PlacementTeamMember__c';
Database.executeBatch(new TestBatch(query), 10000);
Please check once below sample code :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
.. add all required fields