Accounting API Developer's Reference

c2g.BackgroundPostingSchedulerService

global class BackgroundPostingSchedulerService

The service class relating to Background Posting Scheduler.

Properties

Name Type Description
MODE_HOURLY String Used when you want the job to run every hour.
MODE_DAILY String Used when you want the job to run every day.
MODE_WEEKLY String Used when you want the job to run every week.
MODE_MONTHLY String Used when you want the job to run every month.
LAST_DAY String Used when a job should be run on the last day of each month.
MONTH_ITEM_DOM Integer Used when you want the job to run on a specific day every month. For example, on the second day of every month.
MONTH_ITEM_DOW Integer Used when you want the job to run on a specific day every week. For example, on the third day of every week.

Methods

runNow

global static void runNow()

Runs any background posting jobs with a status of “waiting”. See "About the Background Posting Scheduler" in the FinancialForce Help for more details.

runNow

global static void runNow(String documentType)

Runs the background posting scheduler for the specified document type.

Input Parameters

Name Type Description
documentType String The document type for which you want to run the background posting scheduler.

scheduleBySettingsObject

global static c2g.BackgroundPostingSchedulerService.ScheduleResult scheduleBySettingsObject(c2g.BackgroundPostingSchedulerService.ScheduleSettings settings)

Creates a schedule to control the frequency of the batch processing.

Input Parameters

Name Type Description
settings c2g.BackgroundPostingSchedulerService.ScheduleSettings The settings that determine the frequency of the schedule.

Return Value

This service returns a c2g.BackgroundPostingSchedulerService.ScheduleResult object.

Sample Code

//Note: This sample code is for demonstration purposes only, it is not intended for
//use in a production environment, is not guaranteed against defects or errors and
//is in no way optimized or streamlined.

BackgroundPostingSchedulerService.PostingSchedulerConstants constants =
new BackgroundPostingSchedulerService.PostingSchedulerConstants();
BackgroundPostingSchedulerServiceImpl impl =
new BackgroundPostingSchedulerServiceImpl();
// Options for schedule.
String selectedInterval = '1';
String selectedOffset = '0';
Integer selectedMonthItem = constants.MONTH_ITEM_DOM;
String selectedDayOccurance = '1';
String[] selectedWeekDays = new String[]{'1', '3'};
String selectedWeekDay = '1';
String selectedMonthDay = 12;
String selectedTime = '0';
String selectedFrequencyType = 'HOURLY';
// Put the options in a settings object.
BackgroundPostingSchedulerService.ScheduleSettings settings =
new BackgroundPostingSchedulerService.ScheduleSettings(
selectedTime,
selectedFrequencyType,
selectedMonthItem,
selectedMonthDay,
selectedWeekDay,
selectedDayOccurance,
selectedWeekDays,
selectedOffset,
selectedInterval);
BackgroundPostingSchedulerService.scheduleBySettingsObject(settings);

c2g.BackgroundPostingSchedulerService.ScheduleResult

global class ScheduleResult

Holds information about the status of an attempt to schedule.

Sample Code

//Note: This sample code is for demonstration purposes only, it is not intended for
//use in a production environment, is not guaranteed against defects or errors and
//is in no way optimized or streamlined.

// This code is for demonstration purposes only
// Simple check for success.
BackgroundPostingSchedulerService.ScheduleResult result;
result = serviceImpl.scheduleBySettingsObject(completeSettings);
if (result.isScheduled) { //… }

Properties

Name Type Description
isScheduled boolean True if the attempt to create a schedule was successful.
jobs CronTrigger[] An array of the newly scheduled jobs in the form of a CronTrigger array.

c2g.BackgroundPostingSchedulerService.ScheduleSettings

global class ScheduleSettings

This data type allows you to specify the settings of a Background Posting Scheduler schedule.

Sample Code

//Note: This sample code is for demonstration purposes only, it is not intended for
//use in a production environment, is not guaranteed against defects or errors and
//is in no way optimized or streamlined.

BackgroundPostingSchedulerService.PostingSchedulerConstants constants =
new BackgroundPostingSchedulerService.PostingSchedulerConstants();
BackgroundPostingSchedulerServiceImpl impl =
new BackgroundPostingSchedulerServiceImpl();
// Options for schedule.
String selectedInterval = '1';
String selectedOffset = '0';
Integer selectedMonthItem = constants.MONTH_ITEM_DOM;
String selectedDayOccurance = '1';
String[] selectedWeekDays = new String[]{'1', '3'};
String selectedWeekDay = '1';
String selectedMonthDay = 12;
String selectedTime = '0';
String selectedFrequencyType = 'HOURLY';
// Put the options in a settings object.
BackgroundPostingSchedulerService.ScheduleSettings settings =
new BackgroundPostingSchedulerService.ScheduleSettings(
selectedTime,
selectedFrequencyType,
selectedMonthItem,
selectedMonthDay,
selectedWeekDay,
selectedDayOccurance,
selectedWeekDays,
selectedOffset,
selectedInterval);
BackgroundPostingSchedulerService.scheduleBySettingsObject(settings);

Properties

Name Type Description
selectedTime String The hour of the day to run the schedule on.
selectedFrequencyType String The frequency type of the scheduled job. For example, hourly, daily, weekly or monthly.
selectedMonthItem Integer The type of a monthly schedule. For example, the day of the month such as the 5th day of the month or the day of the week, such as the 1st Monday of the month.
selectedMonthDay String The day of the month to run the schedule on.
selectedWeekDay String The day of the week to run the schedule on. For example, 1 for Monday, 2 for Tuesday and so on.
selectedDayOccurance String The selected day to run the schedule on. For example, if selectedWeekDay is Tuesday then giving selectedDayOccurance a value of 2 will make the schedule run on the second Tuesday of the month. Choice of 1 to 4, and 'L' for last occurrence of the month.
selectedWeekDays String[] The day of the week you want the schedule to run. This is only valid if selectedFrequency is WEEKLY. For example, 1 for Sunday, 2 for Monday and so on. Enter more than one string in the array to choose multiple days.
selectedOffset String The minutes past the hour that you want the schedule to run. For example, 15, 30, 45.
selectedInterval String The interval at which you want the schedule to run. For example if you select 3 hours the schedule runs every 3 hours. The limit is 12 hours.

Methods

ScheduleSettings

global ScheduleSettings()