You need to sign in to do that
Don't have an account?

Scheduled Apex Working in Sandbox but not in Production
Hi,
I've created a scheduled Apex class shown below:
global class scheduleContractTriggers implements Schedulable { global void execute(SchedulableContext SC) { List <Contract> contracts = [SELECT OwnerId, Last_Scheduled_Run__c FROM Contract]; for(Contract c : contracts){ if(c.OwnerId != null) c.Last_Scheduled_Run__c = Date.today(); } update(contracts); } }That updates all Contracts and sets a custom field, Last Scheduled Run, to today's date. This scheduled class then triggers an "after update" trigger on Contracts seen below:
trigger cloneExpiringContract on Contract (after insert, after update) { List<Contract> contractsToClone = [SELECT Id, Status, Auto_Renew__c, EndDate FROM Contract]; List<Contract> newContracts = new list<Contract>(); for (Contract c : Trigger.new) { if ((c.Auto_Renew__c == TRUE) && (c.EndDate == Date.today())){ Contract clonedContract = new Contract(); //Contract Details clonedContract.Owner = c.Owner; clonedContract.AccountID = c.AccountID; clonedContract.Opportunity_Name__c = c.Opportunity_Name__c; clonedContract.Status = 'Draft'; //have to save it as a draft first clonedContract.Contract_Type__c = c.Contract_Type__c; clonedContract.Co_Marketing_Opportunities__c = c.Co_Marketing_Opportunities__c; clonedContract.Previous_Contract__c = c.Id; Date newStartDate = c.EndDate.addDays(1); clonedContract.StartDate = newStartDate; clonedContract.ContractTerm = c.ContractTerm; clonedContract.Auto_Renew__c = TRUE; //License Agreement clonedContract.MonthtoMonth__c = c.MonthtoMonth__c; clonedContract.Comments_NDA__c = c.Comments_NDA__c; //NDAs clonedContract.Type_Mutual_One_Side__c = c.Type_Mutual_One_Side__c; clonedContract.Duration__c = c.Duration__c; //Signature Information clonedContract.CustomerSigned = c.CustomerSigned; clonedContract.CustomerSignedDate = c.CustomerSignedDate; clonedContract.CustomerSignedTitle = c.CustomerSignedTitle; clonedContract.CompanySigned = c.CompanySigned; clonedContract.CompanySignedDate = c.CompanySignedDate; newContracts.add(clonedContract); } } insert newContracts; }In Sandbox, the scheduled class was successfully updating the "Last Scheduled Run" field and firing the trigger when applicable. However, when I schedule the class in Production, although it says the scheduled run has succeeded, the "Last Scheduled Run" field is no longer getting populated and therefore the trigger is never fired.
Any suggestions on why this would be or how to fix this are much appreciated.
Also can you check if there is Last_Scheduled_Run__c field available on the Contract object? Does it throw any errors?