Welcome to Zuora Product Documentation

Explore our rich library of product information

Use Whitelist field set - code sample and use case

This task provides a code sample and use case for using the whitelist field set to manage custom fields in Zuora Quotes.

Use the Whitelist field set when a custom field must be available to CPQ X logic, a JavaScript plugin, the Charge Group API, or another headless component but must not be displayed to users in Quote Studio.

The CPQX Quote Information and CPQX Child Quote Information field sets both load fields into the quote data model and render those fields in the Quote Studio user interface. Use a Whitelist field set when the field must be available for processing without being visible to users.

The following code sample demonstrates how the whitelist field set affects the use of custom fields. See Quote Class for information about getInstance global method.

//Assumption: There is a custom text field cf1__c on the zqu__Quote__c object
zqu__Quote__c currentQuote = zqu.Quote.getInstance('<quoteId>').getSObject()
//Scenario 1: The following line will throw an an error 
// "SObject row was retrieved via SOQL without querying the requested field".
System.assertEquals('customFieldText', currentQuote.cf1__c);
//Scneario 2: The custom field was added to a Zuora Quotes fieldSet. 
// The line should not throw an error.
System.assertEquals('customFieldText', currentQuote.cf1__c);
//Scenario 3: The user registered a whitelist fieldSet 
// named "custom_object_fields" and added cf1__c to the fieldSet.
// The line should not throw an error
System.assertEquals('customFieldText', currentQuote.cf1__c);

The following is a sample use case for populating a custom field in the JavaScript plugin using the Whitelist FieldSet Name setting:

  1. Create a field set, named AdditionalCustomFields on the QuoteRatePlanCharge object.
  2. Create a custom field on the QuoteRatePlanCharge object. For example, Cost__c.
  3. Add the Cost__c custom field to the AdditionalCustomFields field set.
  4. In Quote Configuration Settings in the Zuora Config tab, set the value of the Whitelist FieldSet field to AdditionalCustomFields.
    When using Charge Group API or the Product Selector JavaScript plugin, you will see the value of Cost__c included.
    Note:

    The Whitelist FieldSet setting does not replace the rendered Quote Studio field sets. Use the rendered field sets for fields that users must see or edit. Use the Whitelist FieldSet for fields that must be loaded for processing only.