Loading

Contract generation fails in Salesforce CPQ

Data pubblicazione: Jul 2, 2025
Descrizione

In Salesforce CPQ, once a Primary Quote is created, users can either create a contract from an opportunity or create a contract from an order. When the Contracted checkbox is set to True on an opportunity or order and no contract is generated, the information below provides more context as to why contract generation may have failed and how to troubleshoot and resolve the issue. 

Risoluzione

Contracting from an Opportunity

Salesforce CPQ requires the following objects and settings when you create a contract from an opportunity.

  • An opportunity with at least one subscription product
  • A primary quote that looks up to your opportunity
  • A contract-based Renewal Model on your opportunity’s account

To contract your opportunity, select Contracted on your opportunity record, and then save your changes. The contract inherits its start and end dates from your quote’s start and end dates. The contract is created in the background (default process), unless the CPQ package setting Contract in Foreground is set to True. Salesforce CPQ then creates a subscription record for each of your subscription products, assets for non-subscription products that have asset conversion set on the product record, and subscribed assets to connect subscription products to covered assets (for Percent of Total subscription products). 

In order to successfully contract from the Opportunity, two conditions must be met on the Primary Quote:

  1. At least one Quote Line must have the field Subscription Pricing set to “Fixed Price” or “Percent of Total”
    1. This field's value is usually derived from the Quote Line's associated Product record, however, custom automation (i.e. Workflow rules, price rules, etc.) or users can change the product-derived value to a blank value. If there are no Quote Lines that have Subscription Pricing defined, a Contract is not created, but Assets are still created for the Account for Quote Lines of Products with Asset Conversion defined.
  2. A Start Date must be set. Every Quote Line must have an associated Start Date, whether implicit (set on the Parent Quote or Quote Line Group) or explicit (set on the Quote Line itself). The recommendation is to set on the Quote to be absolutely sure that every line has an associated Start Date.

Contracting from an Order

Several conditions that must be true in order for an order to be contracted:
 

  1. The order must have a Status of “Activated”
  2. The order must have a Primary Quote look up record linked to it. If the Quote look-up field is null, no Contract is generated and no error message appears.
  3. The Contracting Service updates the 'Contracted' checkbox on Order Products. If an Order Product's 'Validation Rule' logic is met when doing so, Contracting fails.
  4. The Order Product's Prices feed in from Quote Line: PriceBookEntryId. If any PriceBookEntryId is null, or if any of the related Price Book Entries are inactive, Contracting an Order will encounter this error:
    1. Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Price Book Entry]: [Price Book Entry]"


Find out why a Contract did not generate

  1. User's email address: An email alert is sent from the ContractService apex job to the user who executed the Contracted action if the Contract generation process fails.
  2. The Opportunity record may display an error message at the top if “Contract in Foreground” is checked in package settings.
  3. Specific errors surrounding the ContractService apex job status can be viewed in Apex Jobs.
    1. Navigate to Setup | Apex Jobs
    2. Next, create a list view and set the filter criteria as Status = Failed. 
Known Error Scenarios:
  • The following error message appears when a required field is missing on a related Subscription or Asset record:
First error: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [field]:
  • When the validation rule's error conditions are met and target Asset or subscription creation, users may see the following error message:
First error: Upsert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, ‘error message’
  • When field mapping, twin fields, exists from Quote Line to Subscription or Quote Line to Asset, users may see the error below. In this scenario, the value is sourced from a picklist field but the value is not a valid selection for the receiving field and results in this error:
First error: Insert failed. First exception on row 1; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Picktwin: bad value for restricted picklist field: b: [twin field api name]


This list view provides all Apex failed jobs. Search for ContractQuotesDeferred or ContractService failed apex jobs in order to see the Status Detail for why contracting the opportunity potentially failed. To create a list view of these records:
  1. Navigate to Setup
  2. Apex Jobs
  3. Create a new list view
  4. Filter for jobs that have Status = Failed

In instances where a Contract was generated for a Quote from an Opportunity, but then the Quote was modified with a line deleted, recontracting the Opportunity hits the error: 'Error type: System.NullPointerException 
Reason for error: Attempt to de-reference a null object'. When Creating a Contract from an Opportunity, contracting an opportunity locks the original quote lines from further changes. Deleting the contract or de-populating the SBQQ__Quote__c lookup on the existing contract can temporarily get organizations past the error, but is not recommended with in-flight records. 
Numero articolo Knowledge

000381761

 
Caricamento
Salesforce Help | Article