Custom Batch Chain
In some business models, the standard batch chains as shipped with JustOn may not meet your requirements.
A batch chain is a series of several linked complex operations, which are executed sequentially on multiple records (as selected from list views) at the same time.
Using the custom setting Custom Batch Chain, you can override existing batch chains like, for example, INVOICERUN
. The setting allows for including or excluding batch Apex classes and modifying their execution order.
Info
Overriding batch chains does not affect individual operations triggered from record detail views.
Each Custom Batch Chain setting specifies the following mandatory information:
Field | Type | Description |
---|---|---|
Name | Text | Specifies the name of the batch chain to be modified. Use one Custom Batch Chain setting record for each batch chain. |
Batches | Text (255) | Comma-separated list of batch Apex classes that are to be processed within the customized batch chain. |
Standard Batch Chains
Batch Chain | Apex Classes |
---|---|
INVOICERUN | TransactionBuilderBatchHelper TransactionalInvoiceRunBatchHelper BatchInvoiceRun OpportunityInvoiceRunBatchHelper GenericInvoiceRunBatchHelper MarkAsBilledBatchHelper BatchAssignBalances CreateInstallmentsBatchHelper BuildTransactionTablesBatchHelper |
FINALIZEINVOICE | BatchExternalTaxRetriever BuildTransactionTablesBatchHelper SettleInvoicesBatchHelper BatchFinalizeInvoice BatchAssignBalances BatchExternalTaxRetriever CreateInstallmentsBatchHelper BatchPdfGenerate TransferToPaymillBatchHelper TransactionCsvBatchRenderHelper |
INVOICEEMAILQUEUE | BatchPdfGenerate BatchInvoiceEmailQueue |
EMAILJOB | BatchInvoiceEmail BatchDunningEmail |
Checking batch chain configuration
You can check the configuration of a batch chain executing a script in the Salesforce Developer Console. To check the actual configuration of your INNVOICERUN
chain, for example, run:
List<String> batchNames = new List<String>();
for (ONB2.ChainableBatch b : ONB2.BatchFactory.getInvoiceRun()) {
batchNames.add(String.valueOf(b).substringBefore(':'));
}
System.assert(
false,
String.join(batchNames, ',')
);
Configuring Custom Batch Chain
To override a batch chain, you define a new Custom Batch Chain setting:
-
In Setup, open Custom Settings.
In Salesforce Lightning, navigate to Custom Code > Custom Settings.
In Salesforce Classic, navigate to Develop > Custom Settings.
-
Click Manage in the row of Custom Batch Chain.
- Click New.
-
Specify the details as necessary.
- Name: The name of the batch chain to be modified
- Batches: The batch Apex classes to be processed
-
Click Save.
Info
Create an individual Custom Batch Chain setting record for each batch chain to be modified.
Custom Batch Chain example – INVOICERUN
You have configured the generic invoice run. When the invoice run is finished, you want all invoices to be finalized and sent out via email automatically without user interaction. Use the following setting:
Field | Value |
---|---|
Name | INVOICERUN |
Batches | GenericInvoiceRunBatchHelper, BatchAssignBalances, SettleInvoicesBatchHelper, BatchFinalizeInvoice, BatchPdfGenerate, BatchInvoiceEmailQueue, BatchInvoiceEmail |
Custom Batch Chain example – DUNNINGRUN
Applying this setting automates the creation and distribution of dunning reminders.
Field | Value |
---|---|
Name | DUNNINGRUN |
Batches | DunningRunBatchHelper, BatchFinalizeDunning, BatchPdfGenerate, BatchDunningEmailQueue, BatchDunningEmail |