Scheduling CSV Export
You can schedule exports to run automatically on a regular basis.
The scheduled export requires additional options. To this end, you set up the export to be executed with additional parameters.
The following parameters are available:
| Parameter | Possible Values | Description | Note | Example Values |
|---|---|---|---|---|
| ExportSettings | comma-separated list of export setting names | Specifies which export configuration settings for invoices or booking details are processed when the export runs. | Mandatory | MyCsvExport1, MyCsvExport2 |
| Interval | x(d|w|m) |
Specifies the export period, where x is an integer, d=day, w=week, m=month.To avoid Salesforce database errors, make sure to execute the invoice export at most once a day. |
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.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. |
1-15 |
||
| Alignment | previous, current or next |
Used to describe the Interval position relative to the execution time.Interval = 1m and Alignment = next means that the export period is the next month.Interval = -3m (negative value) and Alignment = current means that the export period is the current and the last two months.Interval = 1w and Alignment = previous means that the export period is the previous week. |
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. | Optional | -5 |
| StartOfWeek | 1 .. 7 |
Specifies the start day of the week, with 1 = Monday ... 7 = Sunday. Defaults to 1 if left empty. |
Optional | 1 |
| PaymentDate | (start|end)(+|-)x |
Specifies the payment date based on the calculated start date or end date, where x is a number of days. |
Optional, applicable for invoice exports only | end-5 |
| CreatePayments | false|true |
Determines whether to create payment balances on the invoices upon exporting. Defaults to false. |
Optional, applicable for invoice exports only | true |
| BusinessEntities | comma-separated list of business entities | Specifies for which business entities the booking details are to be exported. Defaults to all business entities. For compatibility reasons, JustOn supports the parameter name Tenants. |
Optional, applicable for booking detail exports only | EMEA,APAC |
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) |
Alignmentprevious |
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.
Setting up a parameterized export involves two steps:
- Defining parameters for the batch chain
- Scheduling the batch chain:
ExportChain
Configuring Export Batch Chain Parameters
-
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 Nameto be set when scheduling the job - Batch Chain:
ExportChain -
Parameter 1..8: Define batch chain-specific execution options using the syntax
parameter = value, for example,Interval = 2worAlignment = nextTo avoid Salesforce database errors, make sure to execute the invoice export at most once a day.
- Name: Must match the
-
Click Save.
ExportChain parameters example
Export invoices for the current week:
| Field | Value | Description |
|---|---|---|
| Name | week_exp_schedule |
Must match the Job Name to be set when scheduling the job |
| Batch Chain | ExportChain |
|
| Parameter 1 | Interval = 1w |
Sets the invoice run period to one week |
| Parameter 2 | Alignment = current |
Sets the invoice run period to the current interval period |
| Parameter 3 | ExportSettings = OpenInvCSVExport |
Applies the export configuration settings OpenInvCSVExport, which must be defined in Export Settings |
Use a corresponding cron expression to schedule the export for a specific day of the week. If you want, for example, to export the invoices every Saturday night at 23:00, use 0 0 23 ? * 7.
For details, see Scheduling Concepts and Defining Batch Parameters.
Scheduling Export 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:
-
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__JobsSetupto your org's domain name.You can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).
-
From the
Apex Jobdrop-down list, selectBatch Chain Job. - In the
Job Namefield, specify the name of the batch parameters setting created before. - From the
Start Timedrop-down list, select the preferred execution time. -
Click Schedule.
This sets up the export to be executed on a regular basis at the specified time with the additional parameters set.
If you schedule multiple exports, make sure to set different execution times. Concurrently executing multiple instances of the export batch chain may produce errors.
Info
From the Scheduled Jobs page, you can also run the batch chain immediately.
Via Salesforce's 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.
-
Specify the details as required.
- Job Name: The name of the batch parameters setting created before
- Apex Class:
ScheduledBatchChain -
Frequency
To avoid Salesforce database errors, make sure to execute the invoice export at most once a day.
-
Start
- End
- Preferred Start Time
-
Click Save.
This sets up the export to be executed on a regular basis at the specified time with the additional parameters set.
If you schedule multiple exports, make sure to set different execution times. Concurrently executing multiple instances of the export batch chain may produce errors.
For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.