Welcome to Zuora Product Documentation

Explore our rich library of product information

Formula function use cases

Common use cases and code samples of formula function.

Calculate tax due

The following code sample updates the SalesTax__c field with the value of multiplying the purchase amount in the PurchaseAmount__c field by the tax rate in the TaxRate__c field.

((default__vehicle) => {
    const purchaseAmount = default__vehicle.PurchaseAmount__c;
    const taxRate = default__vehicle.TaxRate__c;
    const salesTax = purchaseAmount * taxRate;
    return {
        success: true,
        message: "The sales tax is updated.",
        data: {
            SalesTax__c: salesTax
        }
    };
})(default__vehicle);

Calculate total production cost

The following code sample updates the Total_Production_Cost__c field with the sum of values in the Materials_Cost__c, Labor_Cost__c, and Overhead_Cost__c fields.

((default__manufacturing) => {
    const materialsCost = default__manufacturing.Materials_Cost__c,
    const laborCost = default__manufacturing.Labor_Cost__c,
    const overheadCost = default__manufacturing.Overhead_Cost__c,
    const totalProductionCost = materialsCost + laborCost + overheadCost;
    return {
        success: true,
        message: "The total production cost is updated",
        data: {
            Total_Production_Cost__c: totalProductionCost
        }
    };
})(default__manufacturing);