Use multiply to return the product of two values. Each value can be a numeric field from the record or a string that can be parsed as a number. This is helpful for tasks such as computing extended prices (quantity * unitPrice), applying percentage-based discounts, or adjusting invoice totals.
{{multiply value1 value2}}
-
value1 and value2 can be numbers or numeric strings (e.g.,
"5","10.75"). - The output is a numeric result of the multiplication.
-
Applying a discount
{{multiply record.total "0.9"}}If
record.totalis100, the output is90(a 10% discount). -
Calculating extended price
{{multiply record.quantity record.unitPrice}}If
record.quantityis"3"andrecord.unitPriceis19.99, the output is59.97. -
Combining hard-coded and dynamic values
{{multiply "5" record.items.length}}If
record.items.lengthis4, the output is20.
Tips
Tip
- Make sure each value you pass in can be interpreted as a valid number. Non-numeric strings (like
"abc") result inNaN. - Using double braces ({{ }}) vs. triple braces ({{{ }}}) for the output typically has minimal effect here, since the result is a numeric value.
- When multiplying decimal values, the result can occasionally include trailing digits (for example,
9319.7 x 100returning931970.0000000001instead of931970). This is standard JavaScript floating-point behavior — some decimal values can't be represented exactly in binary — and it isn't specific tomultiplyor Handlebars. To get a clean result, wrap the output with theroundhelper, for example:{{round (multiply record.TotalAmt 100)}}.