> This page is for Docs.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://zuora.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://zuora.ferndocs.com/_mcp/server.

# Formula function use cases

> Common use cases and code samples of formula function.

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);
```

## Copy a custom field value from a related object