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: