Try Serpent Free

How to fix STANDARD_PRICE_NOT_DEFINED in Salesforce deployments

A record needs a Standard Price Book entry for the product, but none has been created yet.

Surfaces during: runtime DML on pricing objects, in CPQ migrations and product setup scripts

What it means

STANDARD_PRICE_NOT_DEFINED means an operation, usually adding a product to a custom price book, or referencing it on a Quote or Opportunity Line, requires the product to already have a Standard Price Book entry, and one doesn't exist. Salesforce treats the Standard Price Book entry as the baseline every custom price book entry is built from.

This ordering requirement is a Salesforce platform rule, not a CPQ-specific one, so it applies whether products are created through the standard UI, Data Loader, or a CPQ package's own provisioning tools.

Diagnosis

Common causes

Custom price book entry created before the standard one
A migration script inserts a custom PricebookEntry for a product without first creating its Standard Price Book entry.
Migration order skips the standard pricebook step entirely
A data load process was scoped around custom price books and never included a step for standard entries.
New product was added directly to a custom price book
A product created through automation or a script was linked straight to a custom price book, bypassing the standard one.

The fix

  1. Insert the Standard Price Book entry first
    Always create a product's Standard Price Book entry before adding it to any custom price book.
    Id standardPbId = Test.getStandardPricebookId();
    insert new PricebookEntry(
        Pricebook2Id = standardPbId,
        Product2Id = productId,
        UnitPrice = 100,
        IsActive = true
    );
  2. Sequence pricing migrations in the right order
    Order the migration so standard entries are created in a separate, earlier step from custom price book entries.
  3. Audit for products missing standard entries
    After a migration, query for products with custom price book entries but no Standard Price Book entry and backfill them.
In practice

How Serpent prevents this

Serpent sequences data-dependent objects the same way it sequences metadata dependencies, so a CPQ migration inserts Standard Price Book entries before any custom price book entries that depend on them. See the Salesforce deployment error library.

Metadata and data in one deployment flow in Serpent

Prevention

Make Standard Price Book entry creation step one of every product-creation script
Bake the standard entry insert into the same script or trigger that creates a new Product2 record, so it can never be skipped.
Get Test.getStandardPricebookId() into every product-related test factory
Standardize test data setup for pricing objects on Test.getStandardPricebookId() from day one, since Apex tests can't query the org's real Standard Price Book Id directly.
Run a periodic audit for products missing standard pricing
Schedule a recurring check for any active Product2 record without an active Standard Price Book entry, so gaps surface before the next migration hits them.
Common questions

STANDARD_PRICE_NOT_DEFINED, answered

Do all custom price books need a standard entry to exist?
Yes. Salesforce requires the product to have an active Standard Price Book entry before it can be added to any other price book.
Can the Standard Price Book entry have a different price than the custom one?
Yes. The Standard Price Book entry just has to exist and be active; the price it holds can differ freely from any custom price book entry for the same product.
How do Apex tests get the Standard Price Book's Id, since it's not queryable normally?
Use Test.getStandardPricebookId() inside test context; querying Pricebook2 for IsStandard = true directly is blocked outside of that test-specific method.

Start free. No credit card, no install, no commitment.

Set up in under 15 minutes. No DevOps hire needed.

Curious about faster shipping before you dive in? Let's talk

Commitment free!