Fine-Tuning Subscription Creation
This document summarizes the subscription builder setup options, irrespective of your business model and your source data.
When generating subscriptions and their corresponding subscription items, the subscription builder always evaluates multiple sources in the following order:
specific mapping documents
records of accordingly configured parent-child objects
remote data received by a REST web service
preconfigured master subscriptions
Thanks to this approach, you can combine multiple sources, providing the corresponding setup.
Info
For an introduction to the subscription builder and details about how to set it up, see Automatically Building Subscriptions.
ON Fields on Objects
The subscription builder requires a number of ON fields on objects if you build subscriptions based on master subscriptions, based on accordingly configured parent-child objects, or based on a data mapping.
Subscription Source Fields
For target objects (with master subscriptions) and parent objects (of a parent-child relationship), the following fields are available:
API Name | Required | Data Type | Description |
|---|---|---|---|
ON_Account | ✅ | Formula (Text) | Specifies the Salesforce account ID or external ID. |
ON_Subscription | ✅ | Lookup (Subscription) | Links to the related subscription. |
ON_SubscriptionBuildError | ✅ | Text (255) | Shows the error message in case the subscription creation has failed. |
ON_MasterSubscription | ✅ | Text (255) | Required when using a master subscription. Specifies the name of the master subscription. |
ON_MappingName | ✅ | Text (255) | Specifies the name of the file that contains the field mapping in JSON to define the data to be retrieved. |
ON_MappingId | ✅ | Text (255) | Specifies the 18-digit, case-safe Salesforce record ID of the file that contains the field mapping in JSON to define the data to be retrieved. |
ON_Mapping | ✅ | Text Area (Long) | Specifies the field mapping in JSON to define the data to be retrieved. |
ON_CurrencyIsoCode | ✅ | Formula (Text) | Sets the subscription currency to the parent object currency if |
ON_UseCase | Text | Defines the use case ( | |
ON_ExcludeFromUpgrade | Formula (Text) | Specifies items to exclude from being cloned and moved to the new subscription during | |
ON_RelatedSubscription | Lookup (Subscription) | Specifies the related subscription, which can be used with the | |
ON_SubscriptionBuilderCriterion | Formula (Text) | The criterion provides an alternative way to specify the target subscription for | |
ON_UpdateSubscription | Checkbox | Controls whether the already generated subscription linked by | |
ON_FieldsToUpdate | ✅ | Text | Specifies the subscription fields to be updated. Expects a comma-separated list of fields, like |
ON_AddNewChildren | Checkbox | Controls whether to create new items from new child records upon subscription update. | |
ON_LastSubscriptionUpdate | DateTime | Shows the time of the last update. Is set automatically when the subscription is updated. | |
ON_BalanceAssignmentKey | Text | Key to match invoices with pre-payment balances of the same source. Set on subscription build, to be copied to the invoice on invoice generation. |
Item Source Fields
For child objects (of a master-detail relationship), the following fields are available:
API Name | Required | Data Type | Description |
|---|---|---|---|
ON_OrderNo | ✅ | Formula (Text) | Key to match source data to a subscription item, must be unique for each detail of the same master. |
ON_Price | ✅ | Formula (Currency) | The net sales price of the item, required if the detail object is defined in subscription build filter. |
ON_Quantity | ✅ | Formula (Number) | The quantity of the item to be invoiced, required if the detail object is defined in subscription build filter. |
ON_Title | ✅ | Formula (Text) | The name or title of the item, required if the detail object is defined in subscription build filter. |
ON_StartDate | Formula (Date) | The service period start of the item. | |
ON_EndDate | Formula (Date) | The service period end of the item. | |
ON_BillingType | Formula (Text) | Specifies whether the object is invoiced once, on a recurring or a transactional base; possible values include | |
ON_BillingPeriod | Formula (Number) | Specifies the time interval (in months) for the item to be considered in an invoice run. | |
ON_BillingUnit | Formula (Text) | Specifies the time frame ( | |
ON_FieldsToUpdate | ✅ | Text | Specifies the item fields to be updated. Expects a comma-separated list of fields, like |
ON_InvoiceLineItemType | Text(255) | Specifies the type of the invoice line item to be built from the subscription item. |
Info
Depending on your use case and its requirements, you can add more fields to have them copied to the generated subscriptions or items, like, for example, ON_StartDate. For an overview of typically used fields, see Best Practice: Subscription Builder Source Data.
ON fields are directly mapped to the subscription or item fields. Fields that are not starting with ON_ can only be referenced and used by a data mapping, or, in case of subscription updates, via the field list in ON_FieldsToUpdate.
Tier Source Fields
For subchild objects (of a lookup relationship or a master-detail relationship), which are used to create price tiers or commission tiers, the following fields are available:
API Name | Required | Data Type | Description |
|---|---|---|---|
ON_Quantity | Formula (Number) | Specifies the item quantity until which the price defined in this tier is valid. If left empty, the defined tier price is valid for all quantities. Tiers are sorted by quantity with empty values last. | |
ON_Price | Formula (Currency) | Specifies the price to apply to quantities within the range of this tier. If left empty, the tier is not considered in the price lookup. | |
ON_Type | Formula (Text) | Specifies the price calculation method of this item for the current price tier ( | |
ON_Target | Formula (Text) | Specifies the target of this tier ( | |
ON_Commission | Formula (Percent) | The commission (percentage value) to apply to the price. | |
ON_StartDate | Formula (Date) | Specifies the first day of the validity period of this tier. | |
ON_EndDate | Formula (Date) | Specifies the last day of the validity period of this tier. | |
ON_SplitQuantity | Formula (Checkbox) | Specifies whether the item is to be split into a new invoice line item when it exceeds the quantity defined in this tier. Can be used for scaled prices or if you want to state a basic charge separately. |
Use Cases
The subscription builder supports three different use cases for the subscription building. They map typical sales use cases:
Use Case | Description |
|---|---|
NEW | Creates a new subscription. |
REORDER | Creates new items and adds them to an existing subscription. If there is no existing subscription, it builds a new subscription. |
UPGRADE | Creates a new subscription, sets an end date on the existing subscription and sets its status to |
Assigning Items to a Related Subscription
If you work with multiple active subscriptions, the use cases REORDER or UPGRADE require the items to be assigned to the related subscription. To this end, set a value in the field ON_RelatedSubscription on the configured target or master object (see ON Fields on Objects). If the field is empty on the first use, the subscription builder creates a new subscription and inserts the subscription ID of the new object. In a subsequent subscription build process, the related subscription is then identified by the value in the field, and the item is assigned to the related active subscription.
Reasons for multiple active subscriptions can be:
doing customer business with different clients via business entities,
setting different payment due terms for the items (on one invoice, all items must have an identical payment due),
offering several invoices to a customer for specific products
Enabling Subscription and Subscription Items Update
Certain business cases require automatically updating existing subscription fields or subscription item fields after the subscription has been built (applying one of the subscription builder use cases). This may be necessary, for example, after the value of a source object field has changed.
To enable the automatic subscription update:
Add the fields
ON_UpdateSubscriptionandON_LastSubscriptionUpdateto the source object.Navigate to the fields list of the source object and create the fields as follows:
API Name | Data Type | Description |
|---|---|---|
ON_UpdateSubscription | Checkbox | Must be selected (by a user or a flow) for the subscription to be updated. |
ON_LastSubscriptionUpdate | DateTime | Is set automatically when the subscription is updated. |
For details, see ON Fields on Objects.
Depending on your business requirements, you can either have users select the checkbox ON_UpdateSubscription manually, or create a custom process to have it set automatically when certain conditions apply.
Make sure not to create the checkbox ON_UpdateSubscription as a formula field. Doing so would produce errors when executing the subscription builder.
Define the target fields to be updated.
To do so, you can either
Set up a data mapping using
fieldsToUpdate(see Using Data Mapping) and configureON_MappingName,ON_MappingIdorON_Mappingon the source object, orAlternatively, configure the field
ON_FieldsToUpdateon the source objects (see ON Fields on Objects)
Optionally, enable the creation of new items from new child records.
To do so, you can either
Configure the field
ON_AddNewChildrenon the parent source object (see ON Fields on Objects)
JustOn evaluates the value of ON_OrderNo to decide whether to update an existing item or to create a new item: With an existing key, JustOn updates the corresponding item, whereas with a new one, it creates a new item.
Alternatively, set up the data mapping
addNewChildrenlikeCODE"addNewChildren":trueand configure
ON_MappingName,ON_MappingIdorON_Mappingon the source object
→ Once set up, selecting the checkbox ON_UpdateSubscription triggers the automatic subscription update. The subscription builder "simulates" the use case NEW and copies the fields selected to be updated. After completing the update, the subscription builder deselects the checkbox ON_UpdateSubscription and sets a date in ON_LastSubscriptionUpdate.
Keeping Track of Source Records
Certain business use cases require keeping track of the source records based on which a subscription and its items have been created, for example, when updating subscriptions. To this end, there are two source fields on the item: SourceParentId and SourceChildId. JustOn automatically fills these fields during the subscription build process.
Once set, the fields keep track of the item's source records. This allows for unequivocally identifying multiple items with the same OrderNo. Following the subscription update example, JustOn only updates items whose values for SourceParentId match the IDs of the parent objects.
Excluding Certain Source Records
Assume that you want to exclude specific source records from being subject to the automatic subscription build based on certain conditions.
JustOn recommends to use a custom field on the source object that is then to be used as an exclude (or include) condition in the subscription build filter. In the easiest way, this custom field is a checkbox that is set using a formula or a flow based on your requirements.
Note
We advise against using validation rules to exclude source records from subscription building. Validation rules are a powerful means to ensure data quality, but this is not your goal here – you just want to set and check one condition. Besides, validation rules may have a considerable performance impact and may have unwanted effects on other business processes.
Think of the following example:
You build subscriptions from opportunities. Usually, the opportunity state is the perfect trigger to invoke the subscription builder: you define a corresponding condition in your subscription build filter. The condition is an expression (as used in an SOQL WHERE clause) that restricts the set of involved records, like Status = 'Activated' – this makes sure that only opportunities of the state Activated will be subject to the subscription build.
The opportunity state, however, may not be enough. Assume you want to exclude opportunities of a certain account. In this case, you add an exclude condition to the filter, like Status = 'Activated' AND ON_Account__c != '<ID>'.
Now assume you want to apply some custom logic to set a "trigger field" based on certain conditions. You create a custom checkbox, like Billable, to include only records where the checkbox is selected, excluding records where the checkbox is not selected. To cover this, your subscription build filter sets this condition: Status = 'Activated' AND Billable__c = true.
Info
You can set up the checkbox as a formula field or use Salesforce flows to have the checkbox selected automatically. This way, you can apply additional logic to determine whether a record is subject to the subscription build or not.