Function overview
This article provides an overview of the function custom logic, including supported objects, function types, triggering events, and function execution mechanisms.
Overview
Functions are user-defined JavaScript code snippets to ensure data integrity and drive automation in your business use cases, such as validating data format or performing complex calculations.
Each function relates to a standard or custom object. When an object record is created or updated, Zuora automatically executes the associated function. You can leverage functions to validate data accuracy and consistency or add additional information based on the calculated results of the functions.
Supported objects
You can create functions for the following objects:
- Account
- Contact
- Credit Memo
- Debit Memo
- Invoice
- Payment
- Payment Method
- Product
- Product Rate Plan
- Product Rate Plan Charge
- Refund
- Subscription
- Subscription Rate Plan charge
- (Any custom object)
The fields that can be used in conditions or return data in functions vary depending on the object type. For more information, see Objects and fields supported by Custom Logic.
Event trigger
According to the function configurations, Zuora can execute functions on either or both of the following events:
- Creation of an object record
- Update of an object record
Function types
Zuora supports the following function types:
- Validation: This type of function takes an object record as input and returns a success indicator, which indicates whether the input field values conform to the validation criteria specified in the function.
- If the function succeeds, Zuora will create or update the object record in your tenant.
- If the function fails, Zuora will display the user-defined error message and not create or update the object record in your tenant.
- Formula: This type of function takes an object record as input, performs calculations on the field values, and returns a success indicator in addition to updated field values.
- If the function succeeds, Zuora will create or update the object record in your tenant with the updated data.
- If the function fails, Zuora will display the user-defined error message and not create or update the object record in your tenant.
What’s next
You can now start creating functions. For more information, see Manage functions.