Welcome to Zuora Product Documentation

Explore our rich library of product information

Custom fields

Learn how to utilize custom fields in Zuora Billing using Mustache templates and access them through a structured JSON data format.

The custom fields available in Zuora Billing can be utilized in the Custom Components screen using Mustache templates. To do this, use the following data structure in the HTML section:
zephr: {
  zuoraData: {
    accounts: [
      {
        id: 'account1', 
        custom_fields: {
          field1: 'value1', 
          field2: 'value2'
        }
      },
      {
        id: 'account2', 
        custom_fields: {
          field1: 'value3', 
          field2: 'value4'
        }
      }
    ]
  }
}
To access values from the provided JSON structure using Mustache templates, use the following examples:
  • To get the value of field1:
    {{zephr.zuoraData.accounts.0.custom_fields.field1}}
  • To get the value of field2:
    {{zephr.zuoraData.accounts.0.custom_fields.field2}}
  • To access field1 from the second account (account2):
    {{zephr.zuoraData.accounts.1.custom_fields.field1}}
  • To access the account ID of the first account:
    {{zephr.zuoraData.accounts.0.id}
  • To iterate through all accounts and list their field1 values:
    {{#zephr.zuoraData.accounts}}
    Account ID: {{id}}, Field1: {{custom_fields.field1}}
    {{/zephr.zuoraData.accounts}}
  • To directly access the custom field of the first account (index 0) from the accounts array in the zephr.zuoraData object.
    {{zephr.zuoraData.accounts.0.custom_fields.preferredName__c}}

    This accesses the preferredName__c field of the first account directly. However, if you still need to evaluate for the first non-null value across multiple accounts, you should keep the original {{#firstNonNull}} syntax, as it serves a different purpose.

  • To adapt the format for accessing the first non-null value, similar to the account ID example:
    {zephr.zuoraData.accounts.0.custom_fields.preferredName__c}}

    This directly accesses the preferredName__c field of the first account. The 0 represents the index of the account in the accounts array. If there are multiple accounts, replace 0 with the appropriate index.

    If you need to retrieve the first non-null value across multiple accounts, use the {{#firstNonNull}} syntax. This function scans the list of accounts and returns the first available (non-null) value for the specified field. For example:
    {{#firstNonNull}}$.zephr.zuoraData.accounts[*].custom_fields.preferredName__c{{/firstNonNull}}
    This checks all accounts and selects the first preferredName__c value that is not null.