DRAFT Price formula reference
When you create a product rate plan charge with the Multi-Attribute Pricing charge model, you have to specify a price formula for the Price Formula field.
A price formula can consist of functions that are used to calculate the actual rating amount for each usage record. Mathematical operations ( +, -, /, * ) are also supported in price formulas. Parentheses can be used to emphasize precedence.
Functions used in price formulas
The following table lists the functions that can be used in price formulas.
Function | Description | Notes | Examples |
---|---|---|---|
fieldLookup("<object>", "<field>") | Returns the value of a field on a standard Zuora object. | Currently, only the “usage” object is supported. |
Examples:
|
max(<argument1>, <argument2>, … ) | Returns the greatest numerical value of the arguments. |
Arguments must be a numeric value, or a function that returns a numerical value. This function supports two or more arguments. |
Examples:
|
min(<argument1>, <argument2>, … ) | Return the smallest numerical value of the arguments. |
Arguments must be a numeric value, or a function that returns a numerical value. This function supports two or more arguments |
Examples:
|
objectLookup("<customObject>", "<targetField>”, [ “<field>”=<value>, ...] ) |
Returns the <targetField> of the specified <customObject>, performing the lookup by using all the provided <field>=<value> criteria. <value> is any supported string, number, or function. It is best practice not to nest objectLookup() functions within each other. |
Currently, the criteria must uniquely identify one row in the custom object. You can specify as many criteria as necessary, using a comma to separate the field/value pairs. |
Examples:
“color__c” = “red”, |
usageQuantity(<argument>) | Returns the quantity for the usage record. This function can contain an optional argument.
|
This function might be useful with certain types of limit scenarios, for example, charging a per-unit charge with a maximum of 100 units. | Examples:
|
effectiveDate(<objectLookup>, "<effectiveDateField>") effectiveDate(<objectLookup>, "<effectiveDateField>", <effectiveDate>) |
Adds effective date semantics to the provided <objectLookup> function. This function is intended for use in custom object lookups where you provide the name of an additional field on the custom object (<effectiveDateField>). The |
The record with a date closest, but earlier than or equal to the effective date value is used. The second form allows the use of a value or function that returns a date or string (yyyy-mm-dd) and uses that instead of the start date in the comparison. |
Examples:
This example uses the start date of the usage to find the appropriate row.
This example ignores the start date of the usage to rate, and all usage for this subscription uses pricing as of June 20, 2019 in the custom object. |
firstValue(<argument1>, <argument2>, …) | Returns the first non-null value from the arguments. | Arguments might be any supported function. This function supports 2 or more arguments. |
Examples:
This example first attempts a lookup of the maker and style, then a lookup of the region, and finally falls back to a hard-coded default value of 0.10.
This example returns the default value of 20.50 if the usage record does not have a defined prerated amount. |