Scheduling Jobs
Scheduling Concepts
Certain business use cases require specific operations to run automatically on a regular basis. JustOn Billing & Invoice Management provides a number of options that facilitate process automation.
With this respect, the following concepts are important:
- Batch chain
-
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.
JustOn Billing & Invoice Management ships a number of ready-to-use batch chains that cover certain business processes.
- Batch parameters
- Batch chains may require additional options. To this end, JustOn Billing & Invoice Management has introduced batch parameters, a type of custom settings that combine a batch chain with specific arguments. Consequently, you can use batch parameters to control the execution behavior of a batch chain.
- Job schedule
-
Finally, you schedule a job. That is, you set up the specific Apex class
ScheduledBatchChain
to execute the intended batch chain at a defined interval. There are two options:- If your batch chain does not need additional parameters, you schedule the job directly for the batch chain.
- If, otherwise, the batch chain requires additional parameters, you schedule the job for the specific batch parameters setting.
The following batch chains are available:
Name | Parameters Required | Description |
---|---|---|
AssignBalancesChain | Executes a balance assignment for all open invoices. | |
BatchBalanceExportJob | Generates booking details from payment balances | |
DunningRunChain | Executes a dunning run for all dunning levels and the corresponding overdue invoices. | |
EmailJobChain | Sends queued invoices and dunnings via email. | |
ExportChain | Exports invoices or booking details to CSV files. | |
InvoiceRunChain | Executes an invoice run. | |
SubscriptionBuilderChain | Executes the subscription builder. | |
SubscriptionPriceIncreaseChain | Executes a subscription price increase. | |
SubscriptionRenewalChain | Executes a subscription renewal. | |
TransactionBuilderChain | Executes the transaction builder. | |
PaymentRunChain | Executes a payment collection for all open invoices if there are payment instruments available for the corresponding account. Requires a payment provider integration via the (legacy) JustOn Self-Service Extension. |
|
VATValidationChain | Executes the VAT validation. |
In a nutshell, setting up JustOn Billing & Invoice Management to automatically execute business processes comprises the following major tasks:
- Optionally, defining a batch parameter setting
-
Scheduling the job, either
- via JustOn's Scheduled Jobs page,
- via the standard Salesforce Schedule Apex functionality, or
- via the Developer Console
Defining Batch Parameters
Batch parameters control the execution behavior of a batch chain, a series of several linked complex operations, which are executed sequentially on multiple records (as selected from list views) at the same time.
Common parameters
Common batch chain parameters that can be used with various batch chains include:
Parameter | Possible Values | Description |
---|---|---|
Interval | x(d|w|m) |
Specifies the period to be considered by the business process (invoice run, export, etc.), where x is an integer, d =day, w =week, m =month.Defaults to 1m . |
x-y |
x and y are positive integers (1 .. 31 ), where x-y specifies a day range for a month. If x>y , then x is considered a day of the previous month. |
|
Alignment | previous , current or next |
Used to describe the Interval position relative to the execution time.Interval = 1m and Alignment = next means that the considered period is the next month.Interval = -3m (negative value) and Alignment = current means that the considered period is the current and the last two months.Interval = 1w and Alignment = previous means that the considered period is the previous week.If not set, defaults to previous . |
ShiftDays | x |
Optional. Usually, the time period calculation is based on the current date. This integer specifies a number of days by which the "anchor date" is to be moved backward or forward. |
StartOfWeek | 1 .. 7 |
Optional. Specifies the start day of the week, with 1 = Monday ... 7 = Sunday. Defaults to 1 if left empty. |
You can define multiple batch parameters settings:
-
Click to enter Setup, then 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 Batch Parameters.
- Click New.
-
Specify the details as required.
- Name: Must match the
Job Name
to be set when scheduling the job - Batch Chain: The name of the batch chain to be executed as listed in Scheduling Concepts
- Parameter 1..8: Define batch chain-specific execution options using the syntax
parameter = value
, for example,Interval = 2w
orAlignment = next
- Name: Must match the
-
Click Save.
Info
The ExportChain, InvoiceRunChain and TransactionBuilderChain require parameters.
Scheduling a Job
There are three ways to schedule a job:
Scheduling JustOn Job
You can schedule a job using JustOn Billing & Invoice Management's Scheduled Jobs page.
-
Open the Scheduled Jobs page.
Use the following URL
https://login.salesforce.com/apex/ONB2__JobsSetup
, or, if you are already logged in, appendapex/ONB2__JobsSetup
to your org's domain name.You can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).
Scheduling a JustOn job -
From the
Apex Job
drop-down list, selectBatch Chain Job
.Batch Chain Job
is a user-friendly label for theScheduledBatchChain
Apex class. -
In the
Job Name
field, specify the name of the batch chain (see Scheduling Concepts) or the name of the batch parameters setting.For details, see Scheduling Concepts.
-
From the
Start Time
drop-down list, select the preferred execution time.Optionally, edit the displayed cron expression to adjust the execution time.
-
Click Schedule.
This sets up the job to execute the selected batch chain at the specified time.
Info
Clicking Run immediately you can execute the batch chain instantly.
Scheduling Apex Class
You can schedule a job using the standard Salesforce Schedule Apex functionality.
-
Click to enter Setup, then open Apex Classes.
In Salesforce Lightning, navigate to Custom Code > Apex Classes.
In Salesforce Classic, navigate to Develop > Apex Classes.
-
Click Schedule Apex on top of the list.
Scheduling an Apex class -
Specify the details as required.
- Job Name: The name of the batch chain (see Scheduling Concepts) or the name of the batch parameters setting
- Apex Class:
ScheduledBatchChain
- Frequency
- Start
- End
- Preferred Start Time
-
Click Save.
This sets up the job to execute the selected batch chain at the specified time.
For more details about Apex job scheduling, see Schedule Apex in the Salesforce Help.
Scheduling Job via the Developer Console
To schedule a batch chain, you can run the ScheduledBatchChain
class in the Salesforce Developer Console, specifying the intended schedule.
-
Open the Developer Console.
For details, see Open the Developer Console in the Salesforce Help.
-
Execute the following code
ONB2.ScheduledBatchChain.setupSchedule(name, schedule);
where
name
is the name of the batch chain or the batch parameters setting (see Scheduling Concepts) andschedule
is a cron expression.This sets up the job to execute the selected batch chain at the specified time.
Scheduling JustOn Billing & Invoice Management Jobs
-
Billing Automation
Scheduling Subscription Build Job
Scheduling Automatic Transaction Build
Scheduling Price Increase Job -
Invoicing Automation
Scheduling Parameterized Invoice Run
Scheduling Monthly Invoice Run
Scheduling VAT Validation -
AR Automation
Scheduling Balance Assignment
Scheduling Payment Collection
Scheduling Dunning Run Job
Scheduling IVA Creation -
Bookkeeping Automation
Scheduling CSV Export
Scheduling Payment Bookkeeping Data Generation
Scheduling Unbilled Revenue Data Generation -
Reporting Automation