---
title: Entering macro expressions
related:
  - https://docs.kentico.com/13/macro-expressions/writing-macro-conditions.md
  - 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).

The Xperience administration interface provides several features that help you:

- Build the macro expressions that you need
- Enter macros into the system

## Using the macro autocomplete help

When typing in dedicated macro editing fields, the system offers an autocomplete assistance feature. The autocomplete also works if you write macro expressions in other locations, for example when editing [email templates](https://docs.kentico.com/13/configuring-xperience/managing-email-templates.md),[transformations](https://docs.kentico.com/13/macro-expressions/writing-transformations-for-macros.md) or **HTML** [page layouts](https://docs.kentico.com/13/custom-development/extending-the-administration-interface/developing-the-administration-using-portal-engine/editing-page-layouts.md).

The autocomplete is similar to IntelliSense in Visual Studio – as you type, a box with the available macro methods and fields appears next to the cursor. If you continue typing, the autocomplete filters the list to include only items that contain the given text. You can navigate through the listed macros using the up and down arrow keys or the mouse. Once you select the appropriate item, press the **Enter**, **Space** or **Dot** key to insert the macro into the text.

When accessing members of macro objects using the dot operator, the autocomplete shows a list of available methods and properties.

If you select a macro method in the autocomplete list, the help displays the method's description and signature (the return type and parameters). _Italics_ identify method parameters that are optional.

![Autocomplete showing members available for string objects (UserName), with details of the selected macro method](https://docs.kentico.com/docsassets/13/entering-macro-expressions/Macro_autocomplete.png "Autocomplete showing members available for string objects (UserName), with details of the selected macro method")

When creating macros within a specialized context, the autocomplete shows related macro fields in a high priority section. You can access prioritized macros at the top of the list, separated by a horizontal line.

> **Tip:** **Tip**: To manually open the macro autocomplete, press **Ctrl + Shift + Space**.

## Inserting macros into text and code fields

The system provides a shortcut for inserting macro expressions in the [WYSIWYG editor](https://docs.kentico.com/13/managing-website-content/editing-rich-text-content.md), macro editors, and other types of code editors that support macros. For example, the feature is available when editing [email templates](https://docs.kentico.com/13/configuring-xperience/managing-email-templates.md), or the text of marketing emails in [newsletters or email campaigns](https://docs.kentico.com/13/on-line-marketing-features/managing-your-on-line-marketing-features/email-marketing/composing-marketing-emails.md).

Click **Insert macro** () on the toolbar above or below the editing area.

![Insert macro button on the WYSIWYG editor toolbar](https://docs.kentico.com/docsassets/13/entering-macro-expressions/TextField_InsertMacro.png "Insert macro button on the WYSIWYG editor toolbar")

The **Insert Macro** dialog opens. You can explore a tree of all available macro options. Click on an item in the tree to insert the given macro into the edited area.

If you wish to write the macro expression directly (with autocomplete support), switch to the **Code** tab, type the macro code and click **Insert**.

![Tree containing the available macro options](https://docs.kentico.com/docsassets/13/entering-macro-expressions/Macro_Tree.png "Tree containing the available macro options")

The macro appears at the current position of the cursor in the edited area, enclosed within the _{% %}_ macro parentheses.

## Setting default form field values through macros

When defining fields for forms in the administration interface through the [field editor](https://docs.kentico.com/13/custom-development/extending-the-administration-interface/developing-form-controls/reference-field-editor.md), you can use macros to set dynamic default values (for both visible and hidden form fields).

Click **Edit value** () next to the **Default value** and write the macro in the Edit value dialog:

- If the field is visible in the editing form, the system  _**resolves the macro directly when users open the form**_.
- If the field is hidden, the macro is resolved when the form is submitted.

![Adding macros into default form field values](https://docs.kentico.com/docsassets/13/entering-macro-expressions/Form_Fields_Macros.png "Adding macros into default form field values")

If you place the macro directly into the **Default value** of text-based fields, the macro appears  _**unresolved**_  in the field when users view the resulting form.

> **Note:** **Note**
>
> When editing fields for [web part properties](https://docs.kentico.com/13/custom-development/extending-the-administration-interface/developing-web-parts/working-with-web-part-properties.md), [form control parameters](https://docs.kentico.com/13/custom-development/extending-the-administration-interface/developing-form-controls/defining-form-control-parameters.md), or the properties of UI page templates, the resolving of macros added into default field values via the **Edit value** () dialog depends on the **Resolve default value** flag.
