Using the API or Apex Actions to Generate Revenue Schedules
If you want revenue schedules to be generated automatically when source records are created, edited, or deleted, you can call the Revenue Management API from your own custom code, or invoke Apex Actions from record-triggered flows.
Using the Revenue Management API
For technical information about the following API services, see the Revenue Management API Developer Reference which is listed in Permission Sets and Other Technical Documentation.
RevenueSchedulesService
The following generate or synchronize methods are available:
- RevenueSchedulesService.generate runs synchronously
- RevenueSchedulesService.generateAsync runs asynchronously
- RevenueSchedulesService.synchronize runs synchronously
The difference between generate and synchronize is that in addition to generating revenue schedules, synchronize also removes obsolete revenue schedules by deleting any where the source record is unavailable. A source record is unavailable if it has been deleted, is no longer active for revenue recognition, or its recognition template has been removed.
See Synchronous and Asynchronous Revenue Schedule Generation for information about how error handling differs depending on whether the process runs synchronously or asynchronously.
RevenueScheduleAutomationService
The RevenueScheduleAutomationService is a global API that allows you to automate the end-to-end process for recognizing revenue against revenue schedules, from generating the schedules through to creating Accounting journals. For more information, see Automation of the End-to-End Process for Recognizing Revenue against Revenue Schedules.
RevenueContractService
If you use the RevenueContractService.create method to create revenue contracts, note that revenue schedules are generated automatically for the revenue contracts. This automatic creation of revenue schedules can be disabled by selecting the Disable Generate Schedules for Contracts field in the Revenue Management Settings custom setting.
Using Apex Actions
You can use Process Builder to configure record-triggered flows to call the following Apex actions which run synchronously:
Apex Action |
Description |
---|---|
Generate Revenue Schedules from source records |
Generates revenue schedules for a source record that is created or updated. We recommend your flow is configured so that the action runs only when a source record is available for revenue recognition i.e. it has a recognition template and is marked as active for revenue recognition. |
Delete Revenue Schedules |
Deletes revenue schedules associated with a source record. Typically a flow will be configured to trigger this action when a source record is deleted. If the source record being deleted has "Complete" revenue schedule lines, those lines are not deleted and the revenue schedule's status is set to "Source Unavailable". For an example, see Configuring a Salesforce Flow to Delete Revenue Schedules When a Source Record Is Deleted. |
Synchronize Revenue Schedules from source records |
Synchronizes revenue schedules with their associated source record. This includes creating revenue schedules if none exist for a source record, updating revenue schedules if the source record has changed, and removing obsolete revenue schedules if the source record is unavailable. A source record is unavailable if it has been deleted, is no longer active for revenue recognition, or its recognition template has been removed. If there are "Complete" revenue schedule lines associated with a source record that is unavailable, those lines are not deleted and the revenue schedule's status is set to "Source Unavailable". For an example, see Configuring a Salesforce Flow to Synchronize Revenue Schedules When a Source Record Is Created or Updated. |