涂煌豪
2022-04-02 75c928f3ef86611c8f7b21e79d2f9b453fdf25f4
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);
    }
}