Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class TriggerManagementSchedulerJob implements Schedulable {
- global static void startSchedule() {
- TriggerManagementSchedulerJob sj = new TriggerManagementSchedulerJob();
- String seconds = '0'; //Execute at Zero Seconds
- String minutes2 = String.valueOf(system.now().addMinutes(10).minute()); //Execute at every 10th minute of hour
- String hours = '*'; // Execute Every Hour
- String dayOfMonth = '*'; // Execute Every Day of the Month
- String month = '*'; //Execute only in November(11)
- String dayOfWeek = '?'; //Execute on all 7 days of the Week
- String year = '*'; //Execute only for year 2009
- String sch = seconds + ' ' + minutes2 + ' ' + hours + ' ' + dayOfMonth + ' ' + month + ' ' + dayOfWeek + ' ' + year;
- system.schedule('TriggerManagementSchedulerJob', sch, sj);
- }
- global void execute(SchedulableContext sc) {
- if (LMSHelper.getCountApexJob() < 5){
- List<Trigger_Assign_Status__c> assignStatuses = [SELECT
- Id, Trigger_Rule__c, Account__c, Contact__c, Case__c, Lead__c, Opportunity__c, User__c
- FROM
- Trigger_Assign_Status__c
- WHERE
- Status__c = :TriggerManagementHelper.TRIGGER_ASSIGN_STATUS_FAILED];
- if (!assignStatuses.isEmpty()){
- Database.executeBatch(new TriggerManagementBatchAssign(
- assignStatuses
- ));
- }
- }
- system.abortJob(sc.getTriggerId());
- TriggerManagementSchedulerJob.startSchedule();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement