Categories
Problem & Solution

Custom order of quote lines in QLE

The Problem

In Salesforce CPQ, you need to sort Quote Lines in the Quote Line Editor, in a custom way, automatically. You want it to happen without user action, always. In this example, we will assume that there are 2 products that always need to be at the bottom of the screen, below any other product in the QLE.

The Solution

In order to deliver that functionality, you need to create 2 custom fields. One field on the SBQQ__Quote__c object and the other on the SBQQ__QuoteLine__c object.

SBQQ__Quote__c field

The field API Name has to be: LineSortField__c, the type must be a formula, of type Text. That formula filed needs to return the API Name of the SBQQ__QuoteLine__c field, which values will be used for sorting the lines. In this example the Quote Line API field name will be as follows:

"QLE_Sort_Order__c"

SBQQ__QuoteLine__c field

Now, you have to create the SBQQ__QuoteLine__c field: QLE_Sort_Order__c, of a formula type, returning Text.

IF(SBQQ__ProductName__c='MySecondLasProduct',
    LPAD(Text(20000),5,"0"),
    IF(SBQQ__ProductName__c='MyLastProduct',
        LPAD(Text(20001),5,"0"),
        LPAD(Text(SBQQ__Number__c),5,"0"))
)

As stated in the problem definition, the above formula returns a high number for 2 products, and the standard QL number handled by CPQ internally.

You may want to read this SF documentation page, for another use case: https://help.salesforce.com/articleView?id=000313434&language=en_US&type=1&mode=1

By Marcin Krzych

Author of "The CPQ Implementation Guide" book. In IT since 2007, In Salesforce ecosystem since 2011, In Salesforce CPQ projects since 2016.
8 SF certifications.

4 replies on “Custom order of quote lines in QLE”

Salesforce will not let me create a formula field of the Quote Line API field name on the quote. It says it does not exist.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.