高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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);
    }
}