Customer 360 for Salesforce
- Customer 360 for Salesforce Spring 2021
- All Products
global class SampleExternalBatch implements Database.Batchable, Database.Stateful{ private Id cloudMDMJobQueueId = null; private Integer itemProcessed = 0; private Integer totalJobItem = 1000; global Database.QueryLocator start(Database.BatchableContext BC) { cloudMDMJobQueueId = API_QueueManager.start(BC); List<string> accountNames = API_QueueManager.getExtendedParameters (cloudMDMJobQueueId, 'AccountName'); List<string> billingCountry = API_QueueManager.getExtendedParameters (cloudMDMJobQueueId, 'BillingCountry'); API_QueueManager.UpdateStatus(cloudMDMJobQueueId, 'start', 0); return Database.getQueryLocator(<>); } global void execute(Database.BatchableContext BC, List scope) { itemProcessed = itemProcessed + scope.size(); API_QueueManager.updateExecutionProgress(cloudMDMJobQueueId, totalJobItem, itemProcessed); } global void finish(Database.BatchableContext BC) { API_QueueManager.finish(cloudMDMJobQueueId, BATCH_STATUS.SUCCESS); } }
API_QueueManager qManager = new API_QueueManager ('CustomBatch', 'ETL_CustomApexBatchJob'); qManager.setQuickParameters (new List<string>{'PARAM1', 'PARAM2', 'PARAM3', 'PARAM4', 'PARAM5', 'PARAM6', 'PARAM7', 'PARAM8'}); qManager.pushExtendedParameters('AccountName', new List<string>{'Informatica', 'EcoLab'}); qManager.pushExtendedParameters('BillingCountry', new List<string>{'USA', 'UK'}); Id batchJobQueueId = qManager.submitJob();
global void finish(Database.BatchableContext BC) { // If more record to process register and loop next chunk or batch if (moreRecordsToProcess ()) { Id newLoopJobId = API_QueueManager.registerJobLoop( cloudMDMJobQueueId); API_QueueManager.submitJob (newLoopJobId); } else { // no more pending records to process. Mark current job as complete API_QueueManager.finish(cloudMDMJobQueueId, BATCH_STATUS.SUCCESS); } }