Accounting Apex API Developer Reference

c2g.AllocationScheduleService

global inherited sharing class AllocationScheduleService

The service class relating to Allocation Schedules.

Enums

RetrieveTransactionsOption

The list of valid options for the range of periods to retrieve transactions from when using a RetrieveTransactionsOption of RetrieveTransactionsByPeriod.

Value Description
RetrieveTransactionsSpecificDates This type allows you to select the From and To dates from which to select transactions.
RetrieveTransactionsByPeriod This type allows you to select the periods from which to select transactions.
RetrieveTransactionsByMonth This type allows you to select the months from which to select transactions.
RetrieveTransactionsFromFirstTransaction This type allows you to select transactions from the date of the first available transaction to a given amount of days before or after the scheduled run date.
RetrieveTransactionsFromDaysPriorToToDate This type allows you to select transactions from a given amount of days before the selected To date, up to a given amount of days before or after the scheduled run date.
RetrieveTransactionsFromLastDates This type allows you to select transactions created since the end of the previous date range up to a given amount of days before or after the scheduled run date. The first ‘From’ date will be derived from previousToDate, which is a required field for RetrieveTransactionsFromLastDates.

RetrieveTransactionsByPeriod

The list of valid options for the range of periods to retrieve transactions from when using a RetrieveTransactionsOption of RetrieveTransactionsByPeriod.

Value Description
Current This type allows you to select transactions from the beginning of the current period in which the schedule runs through to the run date.
Last This type allows you to select transactions from the beginning of the period before the schedule runs through to the end of that period.
Last3 This type allows you to select transactions from the beginning of the third period before the schedule runs through to the end of the period before the schedule runs.

RetrieveTransactionsByMonth

The list of valid options for the range of months to retrieve transactions from when using a RetrieveTransactionsOption of RetrieveTransactionsByMonth.

Value Description
Current This type allows you to select transactions from the beginning of the current month in which the schedule runs through to the run date.
Last This type allows you to select transactions from the beginning of the month before the schedule runs through to the end of that month.
Last3 This type allows you to select transactions from the beginning of the third month before the schedule runs through to the end of the month before the schedule runs.

PostingDateOption

The list of valid options for the calculation of the posting date.

Value Description
SpecificDate This type allows you to define the allocation posting date.
OffsetDate This type allows you to derive the posting date from a specified number of days offset from the run date.

PeriodOption

The list of valid options for how the transaction period will be calculated.

Value Description
RunDate This type allows you to derive the transaction period from the run date
PostingDate This type allows you to derive the transaction period from the posting date.
OffsetDate This type allows you to derive the transaction period from a specified number of periods offset from the posting date.

ScheduleExpiresOption

The list of valid options for defining when the schedule will end.

Value Description
Never This type allows you to define no end date for the schedule. The schedule will continue to run until you manually inactivate it.
After This type allows you to define how many times the schedule will run before it ends.
EndBy This type allows you to define the exact datetime from which schedules will not be run.

Methods

getAllAllocationSchedules

global static List<c2g.AllocationScheduleService.AllocationSchedule> getAllAllocationSchedules()

Return a list of all the allocation schedules. Use ManageAllocations (Manage Allocations) custom permission to grant permissions on this method.

Return Value

This service returns a list of c2g.AllocationScheduleService.AllocationSchedule objects.

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.

List<c2g.AllocationScheduleService.AllocationSchedule> allocationSchedules = c2g.AllocationScheduleService.getAllAllocationSchedules();

getAllSchedulableTemplates

global static List<c2g.AllocationScheduleService.AllocationTemplate> getAllSchedulableTemplates()

Returns all templates available for selection. A template is only available for selection if it has 100% of its total retrieve value distributed. All templates with a company the user has access to will be retrieved. If in single company mode, all companies created in single company mode will also be retrieved.

Return Value

This service returns a list of c2g.AllocationScheduleService.AllocationTemplate objects.

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.

List<c2g.AllocationScheduleService.AllocationTemplate> templates = c2g.AllocationScheduleService.getAllSchedulableTemplates();

deleteAllocationSchedules

global static Set<Id> deleteAllocationSchedules(Set<Id> ids)

Delete all the allocation schedules with the given ids. Use ManageAllocations (Manage Allocations) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
ids Set<Id> A set containing the ids of the allocation schedules to delete.

Return Value

This service returns a set of Id objects.

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.

//Return a list of all the allocation schedules.
List<c2g.AllocationScheduleService.AllocationSchedule> allocationSchedules = c2g.AllocationScheduleService.getAllAllocationSchedules();

//Create a list of ids of schedules we wish to delete
Set<Id> schedulesToDelete = new Set<Id>{};

//In this example we are looping through all of the schedules to find one schedule we wish to delete by name
for (c2g.AllocationScheduleService.AllocationSchedule allocationSchedule : allocationSchedules) {
    if (allocationSchedule.userDefinedName.equals('A schedule')) {
    schedulesToDelete.add(allocationSchedule.id);
    }
}
//Delete the schedule
Set<Id> deletedIds = c2g.AllocationScheduleService.deleteAllocationSchedules(schedulesToDelete);

save

global static Set<c2g.AllocationScheduleService.AllocationSchedule> save(Set<c2g.AllocationScheduleService.AllocationSchedule> dtos)

Save the given allocation schedules. Active schedules will get scheduled. Each active schedule counts towards the Salesforce limit of scheduled Apex jobs. Use ManageAllocations (Manage Allocations) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
dtos Set<c2g.AllocationScheduleService.AllocationSchedule> A set containing the allocation schedules to save.

Return Value

This service returns a set of c2g.AllocationScheduleService.AllocationSchedule objects.

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.

//Create a schedule using the methods of CronSpec
c2g.CronSpec cron = c2g.CronSpec.createHourlyCron('1', '15');

//Get all the available AllocationTemplates
List<c2g.AllocationScheduleService.AllocationTemplate> templates = c2g.AllocationScheduleService.getAllTemplates();

//Select your allocationScheduleTemplates (in this example we are simply selecting them all)
List<c2g.AllocationScheduleService.AllocationScheduleTemplate> scheduleTemplates = new List<c2g.AllocationScheduleService.AllocationScheduleTemplate>();
for (Integer i=0; i<templates.size(); i++) {
c2g.AllocationScheduleService.AllocationScheduleTemplate allocationScheduleTemplate = new c2g.AllocationScheduleService.AllocationScheduleTemplate();
allocationScheduleTemplate.allocationTemplate = templates[i];
allocationScheduleTemplate.sequence = i;
scheduleTemplates.add(allocationScheduleTemplate);
}

//Create an AllocationSchedule
c2g.AllocationScheduleService.AllocationSchedule allocationSchedule = new c2g.AllocationScheduleService.AllocationSchedule();
allocationSchedule.userDefinedName = 'A schedule';
allocationSchedule.description = 'My schedule description';
allocationSchedule.active = true;
allocationSchedule.scheduleExpiresOption = c2g.AllocationScheduleService.ScheduleExpiresOption.After.name();
allocationSchedule.after = 12;
allocationSchedule.retrieveTransactionsOption = c2g.AllocationScheduleService.RetrieveTransactionsOption.RetrieveTransactionsSpecificDates.name();
allocationSchedule.fromDate = Date.valueOf('2014-01-01 00:00:00');
allocationSchedule.toDate = Date.valueOf('2014-02-01 00:00:00');
allocationSchedule.transactionDescription = 'My transaction description';
allocationSchedule.postingDateOption = c2g.AllocationScheduleService.PostingDateOption.OffsetDate.name();
allocationSchedule.postingOffset = 0;
allocationSchedule.periodOption = c2g.AllocationScheduleService.PeriodOption.RunDate.name();
allocationSchedule.allocationScheduleTemplates = scheduleTemplates;
allocationSchedule.cron = cron;

Set<c2g.AllocationScheduleService.AllocationSchedule> toSave = new Set<c2g.AllocationScheduleService.AllocationSchedule>{allocationSchedule};
Set<c2g.AllocationScheduleService.AllocationSchedule> savedSchedules = c2g.AllocationScheduleService.save(toSave);

runNow

global static Set<c2g.AllocationScheduleService.AllocationSchedule> runNow(Set<c2g.AllocationScheduleService.AllocationSchedule> dtos)

Run the given allocation schedules now. Each active schedule counts towards the Salesforce limit of scheduled Apex jobs. Use ManageAllocations (Manage Allocations) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
dtos Set<c2g.AllocationScheduleService.AllocationSchedule> A set containing the allocation schedules to run.

Return Value

This service returns a set of c2g.AllocationScheduleService.AllocationSchedule objects.

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.

//Get all the available AllocationTemplates
List<c2g.AllocationScheduleService.AllocationTemplate> templates = c2g.AllocationScheduleService.getAllSchedulableTemplates();

//Select your allocationScheduleTemplates (in this example we are simply selecting them all)
List<c2g.AllocationScheduleService.AllocationScheduleTemplate> scheduleTemplates = new List<c2g.AllocationScheduleService.AllocationScheduleTemplate>();
for (Integer i=0; i<templates.size(); i++) {
c2g.AllocationScheduleService.AllocationScheduleTemplate allocationScheduleTemplate = new c2g.AllocationScheduleService.AllocationScheduleTemplate();
allocationScheduleTemplate.allocationTemplate = templates[i];
allocationScheduleTemplate.sequence = i;
scheduleTemplates.add(allocationScheduleTemplate);
}

//Create an AllocationSchedule
c2g.AllocationScheduleService.AllocationSchedule allocationSchedule = new c2g.AllocationScheduleService.AllocationSchedule();
allocationSchedule.userDefinedName = 'A schedule to run now';
allocationSchedule.description = 'My schedule description';
allocationSchedule.active = true;
allocationSchedule.retrieveTransactionsOption = c2g.AllocationScheduleService.RetrieveTransactionsOption.RetrieveTransactionsSpecificDates.name();
allocationSchedule.fromDate = Date.valueOf( '2014-01-01 00:00:00');
allocationSchedule.toDate =  Date.valueOf('2014-02-01 00:00:00');
allocationSchedule.transactionDescription = 'My transaction description';
allocationSchedule.postingDateOption = c2g.AllocationScheduleService.PostingDateOption.OffsetDate.name();
allocationSchedule.postingOffset = 0;
allocationSchedule.periodOption = c2g.AllocationScheduleService.PeriodOption.RunDate.name();
allocationSchedule.allocationScheduleTemplates = scheduleTemplates;

c2g.AllocationScheduleService.runNow(new Set<c2g.AllocationScheduleService.AllocationSchedule>{allocationSchedule});

c2g.AllocationScheduleService.AllocationSchedule

global with sharing class AllocationSchedule

This data type allows you to specify an Allocation 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.

c2g.AllocationScheduleService.AllocationSchedule allocationSchedule = new c2g.AllocationScheduleService.AllocationSchedule();
allocationSchedule.userDefinedName = 'A schedule';
allocationSchedule.description = 'My schedule description';
allocationSchedule.active = true;
allocationSchedule.scheduleExpiresOption = c2g.AllocationScheduleService.ScheduleExpiresOption.After.name();
allocationSchedule.after = 12;
allocationSchedule.retrieveTransactionsOption = c2g.AllocationScheduleService.RetrieveTransactionsOption.RetrieveTransactionsSpecificDates.name();
allocationSchedule.fromDate = Date.valueOf('2014-01-01 00:00:00');
allocationSchedule.toDate = Date.valueOf('2014-02-01 00:00:00');
allocationSchedule.transactionDescription = 'My transaction description';
allocationSchedule.postingDateOption = c2g.AllocationScheduleService.PostingDateOption.OffsetDate.name();
allocationSchedule.postingOffset = 0;
allocationSchedule.periodOption = c2g.AllocationScheduleService.PeriodOption.RunDate.name();
allocationSchedule.allocationScheduleTemplates = scheduleTemplates;
allocationSchedule.cron = cron;

Properties

Name Type Description
id Id If updating an existing allocation schedule, this will be its id. If no id is included when saving an allocation schedule, a new allocation schedule will be saved.
userDefinedName String The name of the schedule.
description String The description of the schedule.
name String The system generated name of the schedule. This field is read-only.
active boolean Schedules will only be scheduled when the active boolean is set to true.
ignoreWarnings Boolean Set this value to true to bypass validation warnings. Note that setting ignoreWarnings to true will not bypass error messages.
previousFireTime DateTime The DateTime of the previous schedule to be run. This field is read-only.
nextFireTime DateTime The DateTime of the next schedule to be run. This field is read-only.
createdBy String The user who created the schedule. This field is read-only.
startTime DateTime The DateTime the schedule was originally created. This field is read-only.
currentCompaniesId List<Id> A list of companies which own the schedule object. This field is read-only.
allocationScheduleTemplates List<c2g.AllocationScheduleService.AllocationScheduleTemplate> The list of allocation schedule templates on this allocation schedule.
cron c2g.CronSpec The cron spec object, representing the schedule frequency.
scheduleExpiresOption String This defines how the schedule ends; Never, After or EndBy. The values can be obtained by using .name() on c2g.AllocationScheduleService.ScheduleExpiresOption.
endDate DateTime If a scheduleExpiresOption of EndBy is chosen, this is used to define when the schedule will end. As of this datetime, schedules will not be run.
endDateGenerated DateTime If a scheduleExpiresOption of After is chosen, this is the generated DateTime when the schedule will end. As of this datetime, schedules will not be run. This field is read-only.
after Integer If a scheduleExpiresOption of After is chosen, this is used to define how many times a schedule will run before it expires. The count begins from the startTime, i.e when the schedule was originally created.
retrieveTransactionsOption String This defines how the transaction date range will be calculated; RetrieveTransactionsSpecificDates, RetrieveTransactionsByPeriod, RetrieveTransactionsByMonth, RetrieveTransactionsFromFirstTransaction, RetrieveTransactionsFromDaysPriorToToDate or RetrieveTransactionsFromLastDates. The values can be obtained by using .name() on c2g.AllocationScheduleService.RetrieveTransactionsOption.
fromDate Date If a retrieveTransactionsOption of RetrieveTransactionsSpecificDates is chosen, this is used to define the date from which transaction will be retrieved from.
toDate Date If a retrieveTransactionsOption of RetrieveTransactionsSpecificDates is chosen, this is used to define the date from which transaction will be retrieved until.
retrieveTransactionsByPeriod String If a retrieveTransactionsOption of RetrieveTransactionsByPeriod is chosen, this defines the range of periods to retrieve transactions from; Current, Last or Last3. The values can be obtained by using .name() on c2g.AllocationScheduleService.RetrieveTransactionsByPeriod.
retrieveTransactionsByMonth String If a retrieveTransactionsOption of RetrieveTransactionsByMonth is chosen, this defines the range of months to retrieve transactions from; Current, Last or Last3. The values can be obtained by using .name() on c2g.AllocationScheduleService.RetrieveTransactionsByMonth.
daysPriorToToDate Integer If a retrieveTransactionsOption of RetrieveTransactionsFromDaysPriorToToDate is chosen, this is used to define the transaction range From date based on the given amount of days before the transaction range To date. The daysPriorToToDate must be between -99 and 0.
daysBeforeOrAfterRunDate Integer If a retrieveTransactionsOption of RetrieveTransactionsFromFirstTransaction, RetrieveTransactionsFromDaysPriorToToDate or RetrieveTransactionsFromLastDates is chosen, this is used to define the transaction range To date based on the given amount of days before or after the scheduled run date. The daysBeforeOrAfterRunDate must be between -99 and 99.
previousToDate Date If a retrieveTransactionsOption of RetrieveTransactionsFromLastDates is chosen, and this schedule has not ran before, this is used to define the transaction range From date for the first run.
transactionDescription String The description of the allocation transaction.
postingDateOption String This defines how the allocation posting date will be calculated; SpecificDate or OffsetDate. The values can be obtained by using .name() on c2g.AllocationScheduleService.PostingDateOption.
postingDate Date If a postingDateOption of SpecificDate is chosen, this is used to define the allocation posting date.
postingOffset Integer If a postingDateOption of OffsetDate is chosen, this is used to define the posting date as the specified number of days offset from the run date. The postingOffset must be between -99 and 99.
periodOption String This defines how the transaction period will be calculated; RunDate, PostingDate or OffsetDate. The values can be obtained by using .name() on c2g.AllocationScheduleService.PeriodOption.
periodOffset Integer If a postingDateOption of OffsetDate is chosen, this is used to define the posting date as the specified number of days offset from the run date. The postingOffset must be between -99 and 99.

c2g.AllocationScheduleService.AllocationScheduleTemplate

global with sharing class AllocationScheduleTemplate

This data type allows you to specify an Allocation Schedule Template. A list of Allocation Schedule Templates will be held by every Allocation Schedule. An Allocation Schedule Template is simply an Allocation Template with a sequence number.

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.

c2g.AllocationScheduleService.AllocationScheduleTemplate allocationScheduleTemplate = new c2g.AllocationScheduleService.AllocationScheduleTemplate();
allocationScheduleTemplate.allocationTemplate = myTemplate;
allocationScheduleTemplate.sequence = 1;

Properties

Name Type Description
allocationTemplate c2g.AllocationScheduleService.AllocationTemplate The allocation template.
sequence Integer A sequence number to define what order allocation templates should be posted.

c2g.AllocationScheduleService.AllocationTemplate

global with sharing class AllocationTemplate

This data type represents an Allocation Template. An Allocation Template will be held on every Allocation Schedule Template. An Allocation Schedule Template simply holds the id of an allocation template and its name. A list of all available Allocation Templates can be retrieved via AllocationScheduleService.getAllSchedulableTemplates.

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.

List<c2g.AllocationScheduleService.AllocationTemplate> templates = c2g.AllocationScheduleService.getAllSchedulableTemplates();

Properties

Name Type Description
id Id The id of the allocation template.
name String The name of the allocation template.
description String The description of the allocation template.
© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.