This article explains why Usage record inserts fail inside the Salesforce Billing managed package tier pricing logic and how to resolve the misconfigured Order Product Consumption Schedule that causes it. Customers describe this as: "Trying to insert Usage records via SOAP API and getting a Divide by 0 error", "While loading the Usages, we are getting Error: Attempt to de-reference a null object-878-Class.blng.UsageDomain.calculateSubTotalForTierUsages", and "We get the error: The order product has more than 1 tier for price schedule." The exact stack traces include "Divide by 0-198-Class.blng.TierPricingModel.calculateUnitPrice: line 198", "Attempt to de-reference a null object-878-Class.blng.UsageDomain.calculateSubTotalForTierUsages: line 878", and "Attempt to de-reference a null object-734-Class.blng.UsageDomain.validateTiers: line 734", all originating from Trigger.blng.UsageTrigger during before-insert. Trigger conditions: the Usage record [blng__Usage__c] matches a Usage Summary [blng__UsageSummary__c] whose Order Product Consumption Schedule [blng__OrderProductConsumptionSchedule__c] is missing one or more Order Product Consumption Rates [blng__OrderProductConsumptionRate__c], has a tier with Lower Bound [blng__LowerBound__c] equal to Upper Bound [blng__UpperBound__c] (producing a zero range and the divide-by-zero), has overlapping or duplicated tiers, or has no rate covering the incoming usage quantity. The package setting Usage Rating Process Based On = On Trigger forces tier evaluation at insert time, which is why the error surfaces during the SOAP/Data Loader insert rather than later. Affected: all Salesforce Billing editions (Summer '17 and later) using consumption-schedule-based usage rating.
Use the steps below to identify the misconfigured Order Product Consumption Schedule (OPCS) and its rates, then reload the failed Usage records.
Cause 1: Missing or zero-bound Order Product Consumption Rate (produces 'Divide by 0' at TierPricingModel.calculateUnitPrice line 198)
1. Open the failing Usage Summary record [blng__UsageSummary__c] in the browser. From the related lists, open the Order Product [blng__OrderProduct__c], then open its Order Product Consumption Schedule [blng__OrderProductConsumptionSchedule__c].
2. In the Order Product Consumption Rates [blng__OrderProductConsumptionRate__c] related list, inspect every rate. Confirm that for each rate the Lower Bound [blng__LowerBound__c] is strictly less than the Upper Bound [blng__UpperBound__c]. Lower bounds are inclusive and upper bounds are exclusive.
3. For any rate where Lower Bound equals Upper Bound, edit the rate and set the Upper Bound to the correct next-tier boundary, or delete the rate if it was created in error.
4. For the highest tier, set the Upper Bound [blng__UpperBound__c] to null to make it unbounded.
5. Confirm the Price [blng__Price__c] and Pricing Method [blng__PricingMethod__c] (Per Unit or Flat Fee) are populated on every rate. A null Price triggers the dereference error at UsageDomain.calculateSubTotalForTierUsages line 878.
Cause 2: Multiple tiers exist when only one is expected ('The order product has more than 1 tier for price schedule')
1. Navigate to the Order Product Consumption Schedule linked to the Usage Summary.
2. In the Order Product Consumption Rates related list, count the rates. If more than one rate exists but the product is configured for a single flat tier, delete the extra rates so exactly one rate remains with Lower Bound [blng__LowerBound__c] = 0 and Upper Bound [blng__UpperBound__c] = null.
3. Verify the Type [Type] field on the parent Consumption Schedule [ConsumptionSchedule] is set to either Range or Slab and matches the intended pricing behaviour.
Cause 3: Incoming usage quantity falls outside all defined tiers (produces null dereference at UsageDomain.validateTiers line 734)
1. From the failing Usage record, note the Quantity [blng__Quantity__c].
2. On the linked Order Product Consumption Schedule, confirm that the rates collectively cover the range [0, +infinity). Lower Bound of the first rate must be 0; Upper Bound of the last rate must be null.
3. Add or correct rates so the incoming quantity falls within a defined tier.
After fixing the OPCS for any cause:
1. Navigate to Setup > Installed Packages > Salesforce Billing > Configure > Usage. Confirm the Usage Rating Process Based On setting. If it is On Trigger and you are loading large volumes, set the Data Loader batch size to 1 to avoid concurrent tier evaluation issues, as documented in Salesforce Billing best practices.
2. Re-insert the failed Usage records via SOAP API or Data Loader. The Status [blng__Status__c] field on each Usage must update to Processed and the Unit Price [blng__UnitPrice__c] must inherit from the Usage Summary.
3. Confirm the issue is resolved by re-inserting one of the originally failing Usage records against the same Usage Summary and verifying that the record saves with Status = Processed and that the parent Usage Summary's Unbilled Subtotal [blng__UnbilledSubtotal__c] increments by the expected amount.
005385044

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.