Welcome to Zuora Product Documentation

Explore our rich library of product information

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.

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, Cost__c on the QuoteRatePlanCharge object.
  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.