Guides
GuidesLog In
Guides

Formula Macros

πŸ“˜

Note

Macros are available in Flows Builder Kit version 1.0 or later.

Flows Builder Kit includes powerful Macro components β€” dynamic labels that automatically update based on user properties, actions, or selected products. There are four types of macros available: Answer, System, Product, and Formula.

Formula macro allows you to define dynamic content using JavaScript code that returns a string value. This string will be displayed in the macro label.

Available Variables

answer

An object containing values of all user answers throughout the flow. Example: If you have a step with the ID "email" and want to use that value in your formula, you can access it with answer["email"] or answer.email. The answers can be on the same step or a different step from the Formula Label. When an answer changes, the formula label instantly recalculates with the new answer value.

localeName

The name of the current locale. Example: β€œEnglish” or β€œGerman”.

localeCode

The ID/code of the current locale. Example: β€œen” or β€œde”.

platform

The device platform. Possible values: "iOS", "Android", "Windows", "MacOS", "Linux", null.

timeZone

The current time zone. Equivalent to Intl.DateTimeFormat().resolvedOptions().timeZone.

Available Functions

getProductMacros(macrosId, productIndex = -1, placementId = β€œβ€)

Returns the value of a Product Macro based on the specified parameters. By default, it uses the currently selected product in the current placement.

Parameters:

  • macrosId (string) – The type of product macro you want to retrieve (see list below).
  • productIndex (number, optional) – The index of the product in the placement. Default is -1, which means the currently selected product.
  • placementId (string, optional) – The ID of the placement. Default is an empty string "", which refers to the current placement.

Examples:

Returns the full price of the currently selected product in the current placement:

getProductMacros("full-price")

Returns the full price of the first product (index 0) in the placement with ID "placement-id":

getProductMacros("full-price", 0, "placement-id")

Available macrosId values:

  • full-price
  • old-price
  • new-price
  • discount
  • duration
  • custom-1
  • custom-2
  • custom-3

Formula Examples

Show user email address:

if (answer.email) {
	return "Email: " + answer.email;
} else {
	return "No email";
}

BMI calculator:

const metric = true; // If false, use imperial units
const weight = Number(answer["weight"]) || 0;
const height = Number(answer["height"]) || 0;

let bmi;

if (metric) {
	// Metric calculation (weight in kg, height in meters)
	bmi = weight / (height * height);
} else {
	// Imperial calculation (weight in pounds, height in inches)
	bmi = (703 * weight) / (height * height);
}

// Round to two decimal places
bmi = Math.round(bmi * 100) / 100;

// Interpret BMI result
let interpretation;
if (bmi < 18.5) {
	interpretation = "underweight";
} else if (bmi >= 18.5 && bmi < 25) {
	interpretation = "normal weight";
} else if (bmi >= 25 && bmi < 30) {
	interpretation = "overweight";
} else {
	interpretation = "obese";
}

return `Your BMI is ${bmi}, which is considered ${interpretation}.`;