Knowledge Center

Knowledge Center > Commerce > Zuora for Salesforce Development Resources > Zuora for Salesforce Component Library > Zuora for Salesforce Component Library Samples > Create Your Own "Send to Zuora" Process > Send Custom Fields to Zuora

Send Custom Fields to Zuora

Overview

This topic describes how to send custom fields to Zuora. If you are using Zuora Quotes version 5.3 or later, use the GlobalCustomFieldDefinition class to send custom fields to Zuora. If you are using Zuora Quotes version 5.2 or earlier, send custom Quote and QuoteCharge fields to Zuora.

Zuora Quotes Versions 5.3 and Later

The following sample code describes the use of the GlobalCustomFieldDefinition class to send custom fields to Zuora. You can use this sample code in your own business flow.

See Global Classes for more information. 

Example 1: Retrieve Charge Groups

zqu.GlobalCustomFieldDefinition.CHARGE_FIELDS = new Set<String> { 'My_Custom_Field_1__c', 'My_Custom_Field_2__c' };
this.chargeGroupList = zqu.zQuoteUtil.getChargeGroups(this.quote.Id);

Example 2: Update a Charge Group

Use Global Methods and Components to update a charge group, including standard charge-level field values and custom field values.  
zqu.GlobalCustomFieldDefinition.CHARGE_FIELDS = new Set<String> { 'My_Custom_Field_1__c', 'My_Custom_Field_2__c' };
zqu.zChargeGroup updatedChargeGroup = zqu.zQuoteUtil.updateChargeGroup(this.currentChargeGroup);

Example 3: Send to Zuora

Use Global Methods to send the quote to Zuora, including quote-level and charge-level custom fields.  

zqu.GlobalCustomFieldDefinition.QUOTE_FIELDS = new Set<String> { 'My_Quote_CF_1__c', 'My_Quote_CF_2__c' }; 
zqu.GlobalCustomFieldDefinition.CHARGE_FIELDS = new Set<String> { 'My_Charge_CF_1__c', 'My_Charge_CF_2__c' };
zqu.zSendToZBilling.sendToZBilling(tQuote.Id, 'New', true, null, null); // Note that both quoteFields and chargeFields are passed in as null. 

Limitations

The following limitations apply: 
  • The API name of the custom fields created in Salesforce must match the API name of the custom fields created in Zuora.  
  • Zuora currently only supports limited types of custom fields. Although you can specify any type of custom fields in GlobalCustomFieldDefinition.QUOTE_FIELDS and GlobalCustomFieldDefinition.CHARGE_FIELDS, only the supported types of custom fields will be persisted, retrieved, and displayed by Global Methods and Components. See Configure Custom Fields for the list of supported customer field types.

Zuora Quotes Versions 5.2 and Earlier

The following sample code describes the use of sending custom Quote and QuoteCharge fields to Zuora. This code is a section of a larger apex class. You can use this sample code in your own business flow.

Sample Code

...
...
//Create the Quote Fields
Map<String,String> qFNameMap = new Map<String, String>();
qFNameMap.put ( 'testCustomFieldQuote1__c', 'testing1');
qFNameMap.put ( 'testCustomFieldQuote2__c', 'testing2');

//Create the QuoteCharge Fields
Map<String,Map<String,String>> qcFIDNameValueMap = new Map<String,Map<String,String>>();
Map<String, String> fVMap = new Map<String, String>();
fVMap.put('testCustomFieldQuoteCharge1__c', 'testingQuoteCharge1');
fVMap.put('testCustomFieldQuoteCharge2__c', 'testingQuoteCharge2');
qcFIDNameValueMap.put('a06E0000000Lj02', fVMap);
fVMap.clear();
fVMap.put('testCustomFieldQuoteCharge1__c', 'testingQuoteCharge2A');
fVMap.put('testCustomFieldQuoteCharge2__c', 'testingQuoteCharge2B');
qcFIDNameValueMap.put('a06E0000000Lj01', fVMap);
Map<String, String> resultMap = zqu.zQuoteUtil.sendToZBilling(this.quoteID, this.zBillingAccID, this.overrideFlag, qFNameMap,qcFIDNameValueMap );
if ( resultMap.size() > 0 ){
    for ( String sKey : resultMap.keySet() ){
        this.resultCode = sKey;
        this.resultMessage = resultMap.get(sKey);
    }
}

...
...

Considerations

  • The names of the Salesforce fields and Zuora fields must match.
  • Only fields with string values will be synced.
Last modified
16:37, 8 Aug 2016

Tags

Classifications

(not set)