Custom fields
Learn how to utilize custom fields in Zuora Billing using Mustache templates and access them through a structured JSON data format.
zephr: {
zuoraData: {
accounts: [
{
id: 'account1',
custom_fields: {
field1: 'value1',
field2: 'value2'
}
},
{
id: 'account2',
custom_fields: {
field1: 'value3',
field2: 'value4'
}
}
]
}
}
- 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 theaccounts
array in thezephr.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. The0
represents the index of the account in theaccounts
array. If there are multiple accounts, replace0
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:
This checks all accounts and selects the first{{#firstNonNull}}$.zephr.zuoraData.accounts[*].custom_fields.preferredName__c{{/firstNonNull}}
preferredName__c
value that is not null.