0
votes

I wanted to execute below code in 'Execute Anonymous' window in production every 5 minutes. I don't want to create Batch/Schedule classes at this time.

List<Queue_Member__c> qlistupd = new List<Queue_Member__c>();
for(Queue_Member__c q : [SELECT Id, Name, Last_Assigned_Case__c, Number_of_Open_Cases__c, Login_Status__c, Agent__c, Threshold__c, Chase_owner__c FROM Queue_Member__c]){
    Integer count = [SELECT count() from case where status in ('Open', 'Action Required') and Ownerid = :q.Agent__c and RecordType.Name = 'TASQ OneSource'];
      q.Number_of_Open_Cases__c = count;
      qlistupd.add(q);
}

if(!qlistupd.isEmpty()){
    try{
        update qlistupd;
    }
    Catch(Exception e){
        System.debug('Exception occured' + e);
    }
}

Thanks Kumar

1

1 Answers

0
votes

The only way to do this is to copy your code in Batch class and schedule that class.

Batch/schedule class implementation is quite easy, and you can schedule class with one line of code, something like

System.schedule('Every 0th min of hour', '0 0 * * * ?', new scheduledMerge());