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 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 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 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–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.