---
title: Writing macro conditions
related:
  - https://docs.kentico.com/13/macro-expressions/macro-syntax.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Macro conditions greatly increase the flexibility of certain features. By preparing conditions, you allow the system to dynamically make decisions. For example, when to perform an action, under which circumstances to make an item visible, and so on.

Each condition is defined by a macro expression that returns a true or false value. When the system evaluates the condition, the macro is resolved according to the currently available context data, and the result determines whether the condition is fulfilled or not.

For illustration, the following are examples of functionality that uses macro conditions:

- [Administration interface form fields](https://docs.kentico.com/13/custom-development/extending-the-administration-interface/developing-form-controls/assigning-form-controls-to-fields.md) (visibility and enabled conditions)
- [Marketing automation processes](https://docs.kentico.com/13/on-line-marketing-features/managing-your-on-line-marketing-features/marketing-automation.md) (triggers and step transition conditions)
- [Advanced workflow steps](https://docs.kentico.com/13/configuring-xperience/configuring-the-environment-for-content-editors/configuring-workflows.md) (step transition and branching conditions)

## Entering macro conditions

The user interface provides dedicated fields for entering macro conditions. For example, [dynamic contact groups](https://docs.kentico.com/13/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/segmenting-contacts-into-contact-groups.md) have a **Macro condition** field.

![Macro condition field](https://docs.kentico.com/docsassets/13/writing-macro-conditions/MacroCondition_Interface.png "Macro condition field")

You can choose between two ways of creating macro conditions:

### a) Build the condition out of macro rules

Macro rules are predefined, text-based clauses that define certain requirements. You form the overall condition by combining any number of macro rules. Using macro rules does not require knowledge of K# syntax.

To work with macro rules, click **Edit** next to the condition field. See [Building conditions using macro rules](https://docs.kentico.com/13/macro-expressions/writing-macro-conditions/building-conditions-using-macro-rules.md) for more information.

### b) Write the code of the condition directly

Write a K# macro expression into the condition field. The result must be a boolean value (true/false). Use [macro methods](https://docs.kentico.com/13/macro-expressions/reference-macro-methods.md) with a boolean return type, or comparison and equality operators.

Do not enclose the expression into the standard macro parentheses – the system automatically processes the content of the condition as a K# macro. You can leverage the [macro autocomplete help](https://docs.kentico.com/13/macro-expressions/entering-macro-expressions.md) when typing in condition fields.

> **Tip:** **Tip**: If you wish to add a macro condition field into a custom administration form, use the following [form control](https://docs.kentico.com/13/custom-development/extending-the-administration-interface/developing-form-controls/assigning-form-controls-to-fields.md): **Condition builder**
