Accounting Apex API Developer Reference

c2g.BackgroundPostingSchedulerService

global with sharing 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. Use ScheduleAndRunBackgroundPosting (Schedule and Run Background Posting) custom permission to grant permissions on this method.

runNow

global static void runNow(String documentType)

Runs the background posting scheduler for the specified document type. Use ScheduleAndRunBackgroundPosting (Schedule and Run Background Posting) custom permission to grant permissions on this method.

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. Use ScheduleAndRunBackgroundPosting (Schedule and Run Background Posting) custom permission to grant permissions on this method.

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()

© Copyright 2009–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.