Skip to content

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:

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.
The execution date determines which month is used as the base: if the execution day is before x, the system automatically shifts back one month. See the warning below.
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.

Execution date and day-range intervals

When using a day-range interval (Interval = x-y), the execution date of the scheduled job significantly affects the resulting period.

The system first determines the current interval based on the execution date:

  • If the execution day is within the range (x <= day <= y), the current month is used as the base.
  • If the execution day is before the start of the range (day < x), the system shifts back one month to find the most recent matching interval.

This implicit shift happens before the Alignment parameter is applied. Combining a day-range interval with Alignment = previous can therefore cause a double shift, producing an unexpected date range.

Interval = 16-31, job scheduled to run at the beginning of each month, for example, the 3rd:

Execution Date Base Period
(implicit)
Alignment
previous

current
Dec 3 (day < 16) Nov 16–30 (shifted) Oct 16–31 Nov 16–30
Dec 18 (day >= 16) Dec 16–31 (no shift) Nov 16–30 Dec 16–31

If the scheduled job runs outside the day range (for example, on the 1st–15th for an interval of 16-31), use Alignment = current to avoid the double shift. If the job runs within the day range, Alignment = previous works as expected.

You can define multiple batch parameters settings:

  1. 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.

  2. Click Manage in the row of Batch Parameters.

  3. Click New.
  4. 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 or Alignment = next
  5. 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.

  1. Open the Scheduled Jobs page.

    Use the following URL https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, append apex/ONB2__JobsSetup to your org's domain name.

    You can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).

    alt text
    Scheduling a JustOn job

  2. From the Apex Job drop-down list, select Batch Chain Job.

    Batch Chain Job is a user-friendly label for the ScheduledBatchChain Apex class.

  3. 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.

  4. From the Start Time drop-down list, select the preferred execution time.

    Optionally, edit the displayed cron expression to adjust the execution time.

  5. 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.

  1. 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.

  2. Click Schedule Apex on top of the list.

    schedule_job
    Scheduling an Apex class

  3. Specify the details as required.

  4. 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.

  1. Open the Developer Console.

    For details, see Open the Developer Console in the Salesforce Help.

  2. 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) and schedule 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