Loading

Automatic sort of Quote Lines in the CPQ Quote Line Editor

Publiceringsdatum: Jan 29, 2026
Beskrivning
When Using the Quote Line Editor, CPQ by default sorts quote lines by the quote line number. When reconfiguring bundles, newly added options from the bundle are appended at the bottom of the quote or quote line group in the quote line editor.

The following outlines a sample use case in which a business would like to automatically sort quote lines according to the same order as they appear on the configuration page. We will use a CPQ Special Field for this. In this use case, we use a concatenation of the quote line number of the parent bundle + number field from the Feature + number field from Product Option. The resulting behavior for this use case is that the line editor will re-sort product option quote lines in the same order as they appear in the product feature during bundle configuration, which is the natural order of the bundled configuration.
Lösning

There are four main steps to setting up the quote's LineSortField to automatically sort quote lines in the line editor

  1. Create a product option custom formula to capture the feature order.
  2. Create a quote line custom text Sort Order field
  3. Create a price rule with a formula to determine the value of the Sort Order field
  4. Create the LineSortField on the quote object.


1. Create a product option custom formula to capture the feature order

  1. Navigate to Setup | Objects | Product Option
  2. Create a new field called Feature Number to determine feature order     
    1. Data Type: Formula
    2. Field Label: Feature Number
    3. Field Name: Feature_Number
    4. Formula Return Type: Text
    5. Formula:
      1. LPAD( TEXT( SBQQ__Feature__r.SBQQ__Number__c ), 3, "0")
  3. Save

2. Create a quote line custom text Sort Order field

  1. Navigate to Setup | Objects | Quote Line
  2. Create a new field called Sort Order
    1. Data Type: Text
    2. Field Label: Sort Order
    3. Field Name: Sort_Order
  3. Save


3. Create a price rule with a formula to determine the value of the Sort Order field

  1. Create a price rule
    1. Price Rule Name: Calculate Sort Order
    2. Evaluation Scope: Calculator
    3. Active: True
  2. Create a price action with a source formula that calculates the Sort Order value
    1. Target Object: Quote Line
    2. Target Field: Sort_Order__c
    3. Formula: 
      1. IF(NOT(ISBLANK( SBQQ__RequiredBy__r.SBQQ__Product__c)), LPAD(TEXT(SBQQ__RequiredBy__r.SBQQ__Number__c ), 5, "0"), LPAD( TEXT( SBQQ__Number__c ), 5, "0")) + LPAD(TEXT(SBQQ__ProductOption__r.Feature_Number__c ), 5, "0" ) + LPAD( TEXT( SBQQ__ProductOption__r.SBQQ__Number__c), 5, "0") 


4. Create the LineSortField on the quote object with a formula that references the API name of the quote line field created in step 2.

  1. Navigate to Setup | Objects | Quote
  2. Create a custom formula field called LineSortField
    1. Data Type: Formula
    2. Field Label: LineSortField
    3. Field Name: LineSortField
    4. Formula Return Type: Text
    5. Formula: "Sort_Order__c" - should return the full API name of the Sort Order quote line field in Text (this is a flag for which Quote Line field to sort by).
  3. Save


Considerations:

  1. Please note the above formulas work for a single level bundle without any nested product options that are also nested parent products and is meant to be used as an example. If you use nested bundles, you will need an additional segment in the sort value and a more complex formula. 
  2. The example product option Feature Order formula field and price action Source Formula uses left padding with zeros to accommodate for an alphanumeric sort. For example "10" will come before "2", but "00010" will not come before "00002."
  3. Functionality errors with Groups, Renewals and other processes may occur if the field targeted by LineSortField is not populated across an organization. Admins should set that field to have a value on each Product. 
  4. Users can still use the column sorting in the line editor, however the LineSortField will override column sorting when users calculate or save the quote. 
  5. When a Primary Quote's Quote Lines sync with Opportunity Products, the Opportunity Products are sorted in order by Product Name. The Opportunity Product list can only be manually sorted and will not adhere to the sorting that appears in the Primary Quote. 
  6. Standard Quote Line Numbering sorts through Numbers using natural ordering. If using Quote Line Number field in a designated LineSortField, it's necessary to use LPAD(Text(SBQQ__Number__c),5,"0"). LineSortField is an override using alphanumeric sorting while the Quote Line Number is the original Output for the order rendering, without LPAD lines will use the natural number in the alphanumeric override.
Knowledge-artikelnummer

000381895

 
Laddar
Salesforce Help | Article