> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/experience-cloud/tutorials/general/expressions-for-lwr-sites.md).

# Expressions for LWR Sites

Use the {!expression} syntax on Experience Cloud LWR sites to bind record and CMS data, labels, URL parameters and user fields to component attributes.

## Overview

With expressions, you can make calculations and access property values and other data to pass into the component’s attributes. Use expressions for dynamic output or for passing values into components by assigning them to attributes.

An expression is any set of literal values, variables, subexpressions, or operators that can be resolved to a single value. Method calls aren’t allowed in expressions.

The expression syntax is: **`{!expression}`** where expression is a placeholder.

## Data Binding Expressions

| Expression                        | Description                                                                        | Supported Pages and Components                                                                                                                                                                                                                                                                                                     |
| --------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`{!Item.field}`**               | Gets the data for the field on the current bound data.                             | Anything that’s bound to data. Can include Salesforce CMS or record data.                                                                                                                                                                                                                                                          |
| **`{!Item.field._rawValue}`**     | Gets the raw value for the data field.                                             | Anything that’s bound to CRM data.                                                                                                                                                                                                                                                                                                 |
| **`{!Item.field._displayValue}`** | Gets the formatted and localized value for the data field.                         | Anything that’s bound to CRM data.                                                                                                                                                                                                                                                                                                 |
| **`{!Item._detailURL}`**          | Gets the URL of a Salesforce CMS data item.                                        | Anything that’s bound to a CMS item, including CMS detail pages.                                                                                                                                                                                                                                                                   |
| **`{!Label.namespace.name}`**     | Defines the label’s localized value when you specify labels in Experience Builder. | First, create a translated custom label in Salesforce Setup. For more information, see [Translate Custom Labels](https://help.salesforce.com/s/articleView?id=cl_translate_edit.htm\&language=en_US\&type=5). Then, use the label expression in any Experience Builder component that has a text field to see the localized label. |

## Other Expressions

Use other expressions to query parameters, resolve the correct basePath for a site, or leverage user fields in expressions.

| Expression                                | Description                                                                                                                    | Supported Pages and Components                                                                                                                                                        |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`{!Route.param}`**                      | Gets a query parameter from the URL.                                                                                           | <ul><li>All pages</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul>                                       |
| **`{!param}`**                            | Gets a parameter value from a URL where : precedes the parameter. For example, gets {!term} from the /global-search/:term URL. | <ul><li>All pages with a dynamic parameter in their URL</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul> |
| **`{!Site.basePath}`**                    | Resolves to the basePath of the LWR site.                                                                                      | <ul><li>All pages</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul>                                       |
| **`{!User.userId}`**                      | Resolves to the Salesforce ID of the user.                                                                                     | <ul><li>All pages</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul>                                       |
| **`{!User.isGuest}`**                     | Returns TRUE or FALSE based on whether the user is a guest user.                                                               | <ul><li>All pages</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul>                                       |
| **`{!User.Record.<User sObject Field>}`** | Resolves to the value of a Salesforce User Object’s field.                                                                     | <ul><li>All pages</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul>                                       |
| **`{!User.Commerce.BuyerGroups}`**        | Returns a list of buyer groups associated with the user when used in sites that are built using the Commerce templates.        | <ul><li>All pages</li><li>Out-of-the-box and custom components with string properties</li><li>HTML Editor</li><li>Rich Content Editor</li></ul>                                       |

* When you use the {!param} or {!Route.param} expression in the HTML Editor or Rich Content Editor components, some HTML special characters are escaped, or replaced with different values, for security purposes. These characters include <, >, and &.
* LWR sites don’t support expressions that display authenticated user information, starting with {!CurrentUser.
* Expressions with user data are resolved for Rich Content Editor only on Preview and Published sites.
* When binding User data, you can access all the User sObject fields using the {!User.Record.\<User sObject Field>} expression. You can also use the {!User.Commerce.\<Commerce Field>} expression to access user data related to Commerce in sites built using the Commerce templates. In the Summer ’23 release, only BuyerGroups is supported as a Commerce field.

### Source

<https://developer.salesforce.com/docs/atlas.en-us.exp_cloud_lwr.meta/exp_cloud_lwr/advanced_expressions.htm><br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/experience-cloud/tutorials/general/expressions-for-lwr-sites.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
