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
Austin GutzAustin Gutz 

Scheduled Apex not working

I have a class that compares two fields on an Object and forces an update to trigger a process builder if the fields are a mismatch.

The code works just fine if I run it in the Dev Console.
List<Open_AR_Doc__c> lstINVToUpdate = new List<Open_AR_Doc__c>();
        List<Open_AR_Doc__c> lList = [Select Id, Name, Invoice_Standing__c ,Invoice_Standing_Text__c from Open_AR_Doc__c];
        for(Open_AR_Doc__c inv : lList){
            if(inv.recordTypeId == '0125A000001NaOj' && inv.Invoice_Standing_Text__c != inv.Invoice_Standing__c){
                lstINVToUpdate.add(inv);
            }
        }
        
        if(lstINVToUpdate.size() > 0){
            update lstINVToUpdate;
        }
But when I schedule the class it runs but doesn't actually update the reocrds. 
global class DailyOpenARDocInvoiceUpdate implements Schedulable {

    global void execute(SchedulableContext ctx) {
    
        List<Open_AR_Doc__c> lstINVToUpdate = new List<Open_AR_Doc__c>();
        List<Open_AR_Doc__c> lList = [Select Id, Name, Invoice_Standing__c ,Invoice_Standing_Text__c from Open_AR_Doc__c];
        for(Open_AR_Doc__c inv : lList){
            if(inv.recordTypeId == '0125A000001NaOj' && inv.Invoice_Standing_Text__c != inv.Invoice_Standing__c){
                lstINVToUpdate.add(inv);
            }
        }
        
        if(lstINVToUpdate.size() > 0){
            update lstINVToUpdate;
        }
    }
}


 
Amit Chaudhary 8Amit Chaudhary 8
Please check log you are getting any error while executing the scheduler class ?