Use case: Populate display names and quote lines in Configuration Field Data Set objects
Summarize
Summary of Use case: Populate display names and quote lines in Configuration Field Data Set objects
This guide explains how ServiceNow CPQ customers can enhance their Salesforce (SFDC) integration by automatically populating display names and quote lines in Configuration Field Data Set objects. The Configuration Field Data Set objects capture configuration details after each save from the ServiceNow CPQ configurator, including field variable names and values. However, additional customizations—such as adding user-friendly display names or linking quote lines—require setting up custom Salesforce objects and Apex triggers.
Show less
Prerequisites
- Enable the “Push Config Data to CPQ Salesforce Object” setting in ServiceNow CPQ Admin Settings. This enables creation of Configuration Field Data Set records in SFDC after every save from the configurator.
- Be aware that enabling this setting generates Configuration Field Data Set records even if the quote itself is not saved, potentially creating large data volumes. Disable if not needed and rely on Extended Information in BOM Data instead.
Populating Display Names
To show user-friendly display names for CPQ fields in Salesforce:
- Create a custom SFDC object named LGK Label to store field variable names and their desired display labels.
- Add custom TextArea fields for label and variablename in the LGK Label object.
- Add a Display Name TextArea field to the Configuration Field Data object.
- Create an Apex trigger on Configuration Field Data that, before insert, queries LGK Label for matching variable names and populates the Display Name field accordingly.
Field labels are not automatically imported and require manual or bulk import using one of these methods:
- Manual Creation: Enter LGK Label records one by one for low volume, allowing customized display names.
- Bulk Import from ServiceNow CPQ Fields Export: Export fields from ServiceNow CPQ Admin, filter and import into LGK Label. Suitable for consistent labels across global fields, but excludes set, partner, and system fields.
- Bulk Import from Blueprint Layout Export: Export layout from a ServiceNow CPQ blueprint and import labels. Covers set, system, and partner fields but only fields used in the layout.
After import, you can edit LGK Label records to customize display names further. Add the Display Name field to Configuration Field Data Set page layouts to view the populated names in SFDC.
Populating the Quote Line Field
To associate Configuration Field Data Set records with their corresponding Quote Lines in Salesforce:
- Add a new Lookup Relationship field named Quote Line to the Configuration Field Data object, linking it to the Quote Line object.
- Create an Apex trigger on the Quote Line object that, after insert or update, collects Configuration IDs and updates related Configuration Field Data records with the Quote Line ID.
This linkage enables easier navigation from Configuration Field Data to the BOM and related quote details. Remember to add the Quote Line field to the Configuration Field Data Set layout for visibility.
Important Notes
- Configuration Field Data Sets are created immediately after saving in the ServiceNow CPQ configurator, even before quote saving.
- The Quote Line field on Configuration Field Data will only populate after saving the Quote Line Editor in SFDC.
Learn how to set up custom objects and Apex triggers in SFDC to populate the display names of ServiceNow CPQ fields.
As part of the ServiceNow CPQ Managed Package, the functionality of the Configuration Field Data Set object in SFDC is to return the Configuration ID of the configuration, every field variable name used by the blueprint, the value of that field, and the label of that value after every save from the ServiceNow CPQ configurator:
However, there might be some extra necessities about the configuration in ServiceNow CPQ outside of these fields created by the Managed Package that an organization needs for downstream processes. For instance, we might want to populate the display names of the ServiceNow CPQ fields, or easily jump to the Quote Line of the associated Configuration Field Data objects for an easy connection to the BOM.
With a little setup of custom objects and Apex Triggers in SFDC, these fields can automatically be populated after every configuration is saved.
Prerequisites
Enable “Push Config Data to CPQ Salesforce Object” in the Admin Settings if you have not done so already. This will start creating the Configuration Field Data Sets objects in SFDC.
Populate the display name
- In SFDC Setup, navigate to the Object Manager.
- Create a new custom object called “LGK Label” with the following attributes:
- Record Name: CPQ Label
- Data Type: Auto Number
- Display Format: LGKLB-{0000}
- Allow Search: Checked
- Launch New Custom Tab Wizard after saving this custom object: Checked
- On the New Custom Object Tab page, click the Tab Style field and select any style.
- Click Next, click Next again, and then click Save.
- Click Fields & Relationships on LGK Label, and then click New. Create a new field with the following attributes:
- Data Type: TextArea
- Field Label: label
- Field Name: label
- Click New. Create a new field with the following attributes:
- Data Type: TextArea
- Field Label: variablename
- Field Name: variablename
This new LGK Label object will be where we will host the Field Variable Name and Field Label Name in SFDC. The labels will not automatically be imported. They also must be manually updated/imported every so often with changes and additions to the Fields in CPQ Admin. We will go over methods of bulk import later in this guide.
- In Object Manager, search “Configuration Field Data”.
- Click Fields & Relationships, and then click New. Create a new field with the following attributes:
- Data Type: TextArea
- Field Label: Display name
- Field Name: Display_Name
- Click Triggers, and then click New.
- Paste the following code into the Apex code block:
trigger UpdateConfigurationLabels on LGK__ConfigurationFieldData__c (before insert) { // Step 1: Collect FieldKeys from records to be inserted Set<String> fieldKeys = new Set<String>(); for(LGK__ConfigurationFieldData__c confData : Trigger.new) { fieldKeys.add(confData.LGK__FieldKey__c); } // Step 2: Query LGK_Label__c based on collected FieldKeys Map<String, LGK_Label__c> labelMap = new Map<String, LGK_Label__c>(); for(LGK_Label__c label : [SELECT label__c, variablename__c FROM LGK_Label__c WHERE variablename__c IN :fieldKeys]) { labelMap.put(label.variablename__c, label); } // Step 3: Loop through records to be inserted and update Display_Name__c for(LGK__ConfigurationFieldData__c confData : Trigger.new) { LGK_Label__c matchedLabel = labelMap.get(confData.LGK__FieldKey__c); if(matchedLabel != null) { confData.Display_Name__c = matchedLabel.label__c; } else if(confData.LGK__ValueLabel__c != null) { confData.Display_Name__c = confData.LGK__ValueLabel__c; } }
The framework is complete. Add the new Display Name field to the Configuration Field Data Set layout. All thatʼs left is to import the field label names into the LGK Labels objects. Depending on how you use ServiceNow CPQ Fields, there are three methods of accomplishing this.
|
Manual ServiceNow CPQ Label Creation
|
Pros:
Con: Can be a tedious process for a large number of fields |
|
Bulk Import from exporting all ServiceNow CPQ fields
|
Pros:
Cons:
|
|
Bulk Import from exporting the Blueprint Layout
|
Pros:
Cons:
|
If there are any fields that you’d like to show a different display name than what you have imported, you can easily edit the Label object to whatever label you wish and it will begin populating the Configuration Field Data Sets that way after the update.
Populate the quote line
- In SFDC Setup, Navigate to the Object Manager.
- Search “Configuration Field Data”.
- Click Fields & Relationships, and then click New. Create a new field with the following attributes:
- Data Type: Lookup Relationship
- Related to: Quote Line
- Field Label: Quote Line
- Field Name: Quote_Line
- In Object Manager, search "Quote Line".
- Click Triggers, and then click New.
- Paste the following code into the Apex code block:
trigger PopulateConfigFieldData on SBQQ__QuoteLine__c (after insert, after update) { // Step 1: Collect the Configuration Ids from the new Quote Lines Set<String> configIds = new Set<String>(); Map<String, Id> quoteLineMap = new Map<String, Id>(); // Mapping Configuration UUID to Quote Line Id for (SBQQ__QuoteLine__c ql : Trigger.new) { if (String.isNotBlank(ql.LGK__ConfigurationId__c)) { configIds.add(ql.LGK__ConfigurationId__c); quoteLineMap.put(ql.LGK__ConfigurationId__c, ql.Id); // Storing Quote Line Id } } if (configIds.isEmpty()) { return; } // Step 2: Query the Configuration Field Data records List<LGK__ConfigurationFieldData__c> confFieldsToUpdate = [SELECT Id,LGK__ConfigurationId__c FROM LGK__ConfigurationFieldData__c WHERE LGK__ConfigurationId__c IN:configIds]; // Step 3: Update the Field Data records for (LGK__ConfigurationFieldData__c cf : confFieldsToUpdate) { Id quoteLineId = quoteLineMap.get(cf.LGK__ConfigurationId__c); if (quoteLineId != null) { cf.Quote_Line__c = quoteLineId; // Assigning the Quote Line Id } } update confFieldsToUpdate;
Now, every time a Quote is saved in SFDC, the Quote Line of the Parent Configurable Product will populate into the Configuration Field Data Set. Remember to add this custom field to the Configuration Field Data Sets layout to see it in the tab.