Salesforce CPQ Tutorial 17 - Lookup Queries


Lookup Queries:

A lookup query is a type of query used to search for and retrieve data from related objects. This is used in product rules/price rules to query data from an object (both standard and custom objects) other than a quote. They map the data from the lookup object back to the product rule/price rule.

A lookup query can display any error or validation message and make product selections like - Enable, Disable, Remove, or Add, etc. the product in the Quote line editor.


Advantages of Using Lookup Queries: 

We can keep using Product Rules without Lookup Queries. But there are some advantages of using Lookup Queries with Product Rules- 
Salesforce CPQ Tutorial - Advantages of using Lookup Query with Product Rule or Price Rule

 Use of Lookup Queries with Product Rules:

Use case: In the meal combo bundle product that we have created in this article if the user selects Small in the configuration attribute then all small category products should auto-select and others got deselected. Same if the User selects Large then the other category should be deselected and the Large should get selected. 
Salesforce CPQ Tutorial - Use Case- Use of Lookup Queries

Steps to Configure Lookup Query Using Product Rule: 

  1. Ready Bundle Product- Firstly you need to keep the PVR combo bundle product ready. Please follow the article- Tutorial 7 - Step to Step Guide to Configure CPQ Bundles.  Or create/use any bundle product.
  2. Create a Configuration attribute- Make sure you have a configuration attribute. For example, we have Meal Size as a configuration attribute. We have done this in Tutorial 8 - Twin Fields and Bundle Attributes article.
  3. Create a tab for Lookup Data- By default CPQ package does not provide any tab for Lookup Data. Please create a tab. Steps-
    1. Go to Setup and Search for Tabs
    2. Under Custom Object Tabs create a tab for Lookup Data
  4. Create records under Lookup Data- Lookup data does queries and actions, both types of jobs. Let's check this screenshot -
    Salesforce CPQ Tutorial - Use of Lookup Data

    Here the left side is the Lookup Data record and the Right side is the Quote line editor (QLE) where we have selected the PVR combo product.

    In this example, if the user selects Large in the configuration attribute then we need to disable and Remove the Single Patty Burger from the QLE. So Large is a Category, Single Patty Burger is the Product, and Disable & Remove is the Type

    1. Category: In this field, we need to put the same value that users selected in the configuration attribute. In the above example put Large.
    2. Product: In bundle product, select the product that you want to perform any action based on business requirements. Here I have selected Single Patty Burger.
    3. Type:  this is the action field. If Category matches with the configuration attribute then what action do we need to perform on the selected product, select that action in this field. I have selected Disable and Remove.  
      Similarly add multiple records as I have added - 
      Salesforce CPQ Tutorial - Create Lookup Data Records


      FYI- If you use Disable & Remove in the Type field to remove that product then to get that product back use Enable & Add. If you use Hide & Remove to remove that product then to get that product back use Show & Add.  

  5. Create Product Rule: Now we need to create the product rule with the following values - 
    Name: Meal Selection Using Lookup Query
    Type: Selection
    Scope: Product
    Condition Met: All
    Evaluation Event: Always
    Evaluation Order: 10
    Lookup Object: DBQQ__LookupData__c
    Lookup Type Field: SBQQ__Type__c
    Lookup Product Field: SBQQ__Product__c
    Lookup Required Field: SBQQ__Required__c
    Lookup Message Field: SBQQ__Message__c
    Save the record.

  6. Create Lookup Queries Record: Under the Product rule in the related tab or in the same detail page you will see an option for Lookup Queries. Create the record with the following values- 
    Match Type: Configuration Attribute Value
    Product Rule: Select the Meal Selection Using the Lookup Query that we have created in the above step
    Tested Configuration Attribute: Use the same Configuration Attribute that we have created in step 2 ( Meal Size)
    Operator: equals
    Lookup Field: SBQQ__Category__c
    Save the record.

  7. Add Configuration Rule: Add the configuration record for the same Product Rule with the following values -
    Action: True
    Product: Select your Bundle Product that we have created in step 1 ( PVR Combo)
    Product Rule: Select the Product Rule that we have created in step 5 (Meal Selection Using Lookup Query)
    Save the record.

Congratulations!! You made it... Here is the live demo of your Lookup Queries -
 
Salesforce CPQ Tutorial - Lookup Queries Live Demo