Custom Action to Renew Contracts
You can implement customizations to renew contracts automatically. You can do this programmatically via the API, or you can do it without writing code by invoking the following Apex action from a Salesforce flow:
Category |
Apex Action | Apex Class | Purpose |
---|---|---|---|
Billing Contract | Renew Billing Contracts Asynchronously | ContractsServiceActionRenewAsync |
Takes a collection of billing contract IDs and creates renewal contracts with the status "Draft" based on supplied pricing and date input options. |
The process runs asynchronously using Queueable Apex. When you supply a collection of contract IDs to the Apex action, they are split into groups and processed. The group size is determined by the Renew Contracts: Scope Size field in the Background Process Settings custom setting.
Input Parameters
The Renew Billing Contracts Asynchronously Apex action has the following input parameters for each billing contract passed to it.
For more information about creating renewals using the different pricing and duration options, see Renewals.
Parameter |
Required or Optional |
Description |
---|---|---|
Billing Contract ID to be renewed | Required | ID of the contract to be renewed. |
Contract duration option | Required |
Specify whether the renewal's duration is the same number of days, or the same number of months, as the active contract. You must supply one of the following supported values. They are case-insensitive.
|
Contract line duration option | Required |
Specify whether contract line items on the renewal have the same start and end dates as on the active contract, or have their start and end dates extended to the renewal's start and end dates. You must supply one of the following supported values. They are case-insensitive.
|
Percentage | Optional |
The percentage by which unit prices are updated on the renewal. This must be a decimal value. See "More Information about the Pricing Options" below. |
Pricebook ID | Optional |
The price book from which to obtain unit prices for the renewal. See "More Information about the Pricing Options" below. |
More Information about the Pricing Options
If you supply both Percentage and Pricebook ID, an error is reported and the renewal is not created.
If you supply neither Percentage nor Pricebook ID, the renewal is created with the existing unit prices.
If you supply a percentage with decimal places, depending on the unit prices on the active contract, unit prices on the renewal might end with very small numbers which could result in rounding issues. For example, if the unit price is 0.01 and the percentage is 0.01 the unit price on the renewal will be 0.010001. We recommend you check the unit prices on your renewals before activating them.
Output Values to Store for Error Handling
By default, errors are recorded in Billing Central logs. If you prefer to notify the user by email when an error occurs during the flow, you can store the return values in resources which are available to other flow elements. For an illustration of how to do this, see Sample Flows to Renew Contracts.
When configuring the action in a flow, click Advanced and select the Manually Assign Variables checkbox to store the following return values.
Output Variable |
Description |
---|---|
Billing Contract ID to be renewed | ID of the contract that has been queued for renewal. |
Has Errors | Assign this to a boolean variable to store the outcome of the renewal action, so it can be used by a Decision element later in the flow. |
Error Message | Assign this to a text variable which can be used to store the error message so that an Action element can email it to the user. |
Permissions
To configure a Salesforce flow to use this Apex action, you must be assigned a permission set that includes access to the corresponding Apex class. The class is included in the following packaged permission set:
- Billing Central API
For more information about creating Salesforce flows, see the Salesforce Help.
Sample Flows to Renew Contracts
For illustrations of how flows can be configured to use this Apex action, see Sample Flow to Renew Contracts Using Fixed Input Parameters and Sample Flow to Renew Contracts Using Input Parameters Derived from Fields on Account Extension.