global class ConsumApplyInventoryAutoDeleteSchedule implements Schedulable { global void execute(SchedulableContext sc) { List camList = [SELECT Id , Key__c , ValueLong__c FROM Consum_Apply_Meta__mdt WHERE Package__c = 'InventoryAutoDeleteBatch' AND Key__c = 'dateLimit']; Integer dateLimit = 2; for (Consum_Apply_Meta__mdt camt : camList) { dateLimit = Integer.valueOf(camt.ValueLong__c); } Database.executeBatch(new ConsumApplyInventoryAutoDeleteBatch(dateLimit), 200); } }