function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alejandro RosanoAlejandro Rosano 

Schedule a batch at certain hours

Hello all,

I made a schedulable batch that I want to run at certain hours, let's say 6, 12 and 18. I'm writting those hours in a custom setting CS_Schedule__c. How can I call that CS from Apex and get the hours?

Thanks in advance.
Best Answer chosen by Alejandro Rosano
VinojVinoj
Hi Alejandro,

The custom setting can be queried as if it were a custom object.  Assuming your CS_Schedule__c is a list type with a single field called Hour you can access it like this:
 
List<CS_Schedule__c> sList = [SELECT Hour__c FROM CS_Schedule__c];

for (CS_Schedule__c s : sList) {
	System.debug(s.Hour__c);
}