Skip to content

Scheduling Jobs

Scheduling Concepts

Certain business use cases require specific operations to run automatically on a regular basis. JustOn provides a number of options that facilitate process automation.

With this respect, the following concepts are important:

A batch chain is a series of multiple linked complex processes, which are executed sequentially on manageable chunks of large data sets. JustOn ships a number of ready-to-use batch chains that cover certain business processes.

Batch chains may require additional options. To this end, JustOn 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.

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.
DunningRunChain Executes a dunning run for all dunning levels and the corresponding overdue invoices.
EmailJobChain Sends queued invoices and dunnings via email.
InvoiceRunChain Executes an invoice run.
InvoiceStatisticsChain Updates invoice statistics for the Invoice Statistics extension.
SubscriptionBuilderChain Executes the subscription builder.
SubscriptionPriceIncreaseChain Executes a subscription price increase.
SubscriptionRenewalChain Executes a subscription renewal.
TransactionBuilderChain Executes the transaction builder.

In a nutshell, setting up JustOn to automatically execute business processes comprises the following major tasks:

Defining Batch Parameters

Batch parameters control the execution behavior of a batch chain. You can define multiple batch parameters settings:

  1. In Setup, 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>
  5. Click Save.

Scheduling a Job

There are three ways to schedule a job:

Scheduling JustOn Job

You can schedule a job using JustOn's Scheduled Jobs page.

Info

The Scheduled Jobs page is available as of JustOn 2.44.

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
    For more information about Visualforce pages, see Managing Visualforce Pages in the Salesforce Help.
    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 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.
  5. Optionally, edit the displayed cron expression to adjust the execution time.
  6. Click Schedule.
    ▶ This sets up the job to execute the selected batch chain at the specified time.

Scheduling Apex Class

You can schedule a job using the standard Salesforce Schedule Apex functionality.

  1. In Setup, 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.
    • Job Name: The name of the batch chain or the name of the batch parameters setting (see Scheduling Concepts)
    • Apex Class: ScheduledBatchChain
    • Frequency
    • Start
    • End
    • Preferred Start Time
  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 Invoice Run

You can schedule the invoice run to have invoices created automatically on a regular base.

Parameterized Invoice Run

The scheduled invoice run may require additional options. To this end, you can set up the invoice run to be executed with additional parameters.

The following parameters are available:

Parameter Possible Values Description Example Values
Interval x(w|m) Specifies the execution interval, where x is an integer, w=week, m=month. Defaults to 1m. 2w
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. 1-15
Alignment previous, current or next Used to describe the relative interval position to the execution time. If the interval is set to 1m (= 1 month), for example, the value next means that the time period for the invoice run will be the next month. If the interval is set to a negative value, like -3m with the alignment current, then the time period will be the current and the last two months. If not set, it defaults to previous. next
ShiftDays x 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. -5
StartOfWeek 1 .. 7 Specifies the start day of the week, with 1 = Monday ... 7 = Sunday. Defaults to 1if left empty. 1
InvoiceDate (start|end)(+|-)x Specifies the invoice date based n the start date or end date of the invoice run, where x is a number of days. end-5
InvoiceRunFilter <string> Specifies the name of a filter to be applied as taken from the custom setting Filters <filter name>
OpportunityInvoiceRunFilter <string> Specifies the name of a opportunity filter to be applied as taken from the custom setting Filters <filter name>
TransactionFilters <string> Specifies the names of the transaction filters to be applied as taken from the custom setting Filters (comma-separated list) <filter name list>
GenericFilters <string> Specifies the names of the generic invoice run filters to be applied as taken from the custom setting Filters (comma-separated list) <filter name list>

Info

If the calculated invoice run period and the specified filters belong to an existing invoice run, then JustOn uses the existing invoice run instead of creating a new one.

Setting up a parameterized invoice run involves two steps:

  • Defining parameters for the batch chain
  • Scheduling the batch chain

Configuring Batch Chain Parameters

  1. In Setup, 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: InvoiceRunChain
    • Parameter 1..8: Define batch chain-specific execution options using the syntax <parameter> = <value>
  5. Click Save.
Batch Chain Parameters Example
FieldValueDescription
Nameir_schedule_1Must match the Job Name to be set when scheduling the job
Batch ChainInvoiceRunChain
Parameter 1Interval = 2wSets the execution interval to two weeks
Parameter 2InvoiceDate = end-1Sets the invoice date to the penultimate day of the invoice run period
Parameter 3InvoiceRunFilter = MySubscriptionsSets the invoice run filter to MySubscriptions, which must be defined in Filters
Parameter 4TransactionFilters = Cases,OrdersSets the transaction filters to Cases and Orders, which must be defined in Filters

Scheduling Batch Chain

To schedule the batch chain, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
  2. From the Apex Job drop-down list, select Batch Chain Job.
  3. In the Job Name field, specify the name of the batch parameters setting created before.
  4. From the Start Time drop-down list, select the preferred execution time.
  5. Click Schedule.
    ▶ This sets up the invoice run to be executed on a regular base at the specified time with the additional parameters set.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. In Setup, 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.
  3. Specify the details as required.
    • Job Name: The name of the batch parameters setting created before
    • Apex Class: ScheduledBatchChain
    • Frequency
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the invoice run to be executed on a regular base at the specified time with the additional parameters set.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Monthly Invoice Run

You can schedule the invoice run to have invoices created automatically once a month. To do so:

  1. In Setup, 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_ir_job
    Scheduling the invoice run
  3. Specify the details as required.
    • Job Name
    • Apex Class: ScheduledMonthlyInvoiceRun
    • Frequency: Monthly with an according day of month setting
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the invoice run to be executed on a regular base at the specified time.

For the invoice run parameters, the following values are applied by default:

Invoice Run Parameter Value
Start Date Sets the first day of the month before the invoice run has been executed
End Date Sets the last day of the month before the invoice run has been executed
Invoice Date If empty, sets the date of the invoice run execution

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Scheduling Price Increase Job

The price increase job does not require additional parameters. That is, you can set up the job directly for the corresponding batch chain SubscriptionPriceIncreaseChain. For details, see Scheduling Concepts.

To schedule the price increase batch chain, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
  2. From the Apex Job drop-down list, select Batch Chain Job.
  3. In the Job Name field, specify SubscriptionPriceIncreaseChain.
  4. From the Start Time drop-down list, select the preferred execution time.
  5. Optionally, edit the displayed cron expression to adjust the execution time.
  6. Click Schedule.
    ▶ This sets up the subscription price increase (see Configuring Subscription Price Increases) to be executed at the specified time.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. In Setup, 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.
  3. Specify the details as required.
    • Job Name: SubscriptionPriceIncreaseChain
    • Apex Class: ScheduledBatchChain
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the subscription price increase (see Configuring Subscription Price Increases) to be executed at the specified time.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Scheduling Subscription Build Job

You can set up a job in order to have subscriptions build automatically on a regular basis.

The subscription build job does not require additional parameters. That is, you can set up the job directly for the corresponding batch chain SubscriptionBuilderChain. For details, see Scheduling Concepts.

To schedule the subscription build batch chain, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
  2. From the Apex Job drop-down list, select Batch Chain Job.
  3. In the Job Name field, specify SubscriptionBuilderChain.
  4. From the Start Time drop-down list, select the preferred execution time.
  5. Optionally, edit the displayed cron expression to adjust the execution time.
  6. Click Schedule.
    ▶ This sets up the subscription build to be executed at the specified time.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. In Setup, 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.
  3. Specify the details as required.
    • Job Name: SubscriptionBuilderChain
    • Apex Class: ScheduledBatchChain
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the subscription build to be executed at the specified time.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

You can also invoke the subscription builder using the following code in the Force.com Developer Console (see Developer Console Functionality in the Salesforce Help):

new ONB2.ChainRunner()
.execute(
    new ONB2.ChainFactory().getByName('SubscriptionBuilderChain')
);

Scheduling Transaction Build Job

To schedule the transaction build process, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
  2. From the Apex Job drop-down list, select Batch Chain Job.
  3. In the Job Name field, specify the name of the batch parameters setting, for example buildtransactions.
  4. From the Start Time drop-down list, select the preferred execution time.
  5. Optionally, edit the displayed cron expression to adjust the execution time.
  6. Click Schedule.
    ▶ This sets up the transaction build process to be executed at the specified time.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. In Setup, 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.
  3. Specify the details as required.
    • Job Name: The name of the batch parameters setting, for example buildtransactions
    • Apex Class: ScheduledBatchChain
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the transaction build process to be executed at the specified time.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Scheduling Balance Assignment

You can set up a job in order to have balances automatically assigned to open invoices on a regular basis.

The balance assignment job does not require additional parameters. That is, you can set up the job directly for the corresponding batch chain AssignBalancesChain. For details, see Scheduling Concepts.

To schedule the balance assignment batch chain, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
  2. From the Apex Job drop-down list, select Batch Chain Job.
  3. In the Job Name field, specify AssignBalancesChain.
  4. From the Start Time drop-down list, select the preferred execution time.
  5. Optionally, edit the displayed cron expression to adjust the execution time.
  6. Click Schedule.
    ▶ This sets up the balance assignment to be executed at the specified time.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. In Setup, 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.
  3. Specify the details as required.
    • Job Name: AssignBalancesChain
    • Apex Class: ScheduledBatchChain
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the balance assignment to be executed at the specified time.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Scheduling Basware Notification Retrieval

If you distribute electronic invoices via Basware, you can set up a job in order to retrieve notifications for the processed invoices from Basware on a regular basis.

The Basware notifications job does not require additional parameters. That is, you can set up the job directly for the corresponding Apex class ScheduledBaswareNotifications. For details, see Scheduling Concepts.

To schedule the Basware notifications job, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.
    Open the JobsSetup page directly, or navigate to Visualforce Pages > JobsSetup in Setup, and open the preview.
  2. From the Apex Job drop-down list, select Basware Notifications Job.
    The Job Name field is automatically set to ScheduledBaswareNotifications.
  3. From the Start Time drop-down list, select the preferred execution time.
  4. Optionally, edit the displayed cron expression to adjust the execution time.
  5. Click Schedule.
    ▶ This sets up the Basware notification retrieval to be executed at the specified time.

Info

From the Scheduled Jobs page, you can also run the job immediately.

Via Salesforce's Schedule Apex functionality:

  1. In Setup, 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.
  3. Specify the details as required.
    • Job Name
    • Apex Class: ScheduledBaswareNotifications
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.
    ▶ This sets up the Basware notification retrieval to be executed at the specified time.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Return to JustOn Administration.