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
SivaGSivaG 

Execute anonymous apex code in production

Hi,

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
Best Answer chosen by SivaG
Andy BoettcherAndy Boettcher
You could use the Force.com CLI to schedule commands from your server/workstation to do this.  https://force-cli.heroku.com/