高章伟
2022-03-18 a0bc3e3af59aed35334bdc38256a7a1dfe8aecf3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
global class ConsumApplyInventoryAutoDeleteSchedule  implements Schedulable {
    global void execute(SchedulableContext sc) {
        List<Consum_Apply_Meta__mdt> 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);
    }
}