Expressions for LWR Sites
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 |
---|---|---|
| Gets the data for the field on the current bound data. | Anything that’s bound to data. Can include Salesforce CMS or record data. |
| Gets the raw value for the data field. | Anything that’s bound to CRM data. |
| Gets the formatted and localized value for the data field. | Anything that’s bound to CRM data. |
| Gets the URL of a Salesforce CMS data item. | Anything that’s bound to a CMS item, including CMS detail pages. |
| 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. 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 |
---|---|---|
| Gets a query parameter from the URL. |
|
| Gets a parameter value from a URL where : precedes the parameter. For example, gets {!term} from the /global-search/:term URL. |
|
| Resolves to the basePath of the LWR site. |
|
| Resolves to the Salesforce ID of the user. |
|
| Returns TRUE or FALSE based on whether the user is a guest user. |
|
| Resolves to the value of a Salesforce User Object’s field. |
|
| Returns a list of buyer groups associated with the user when used in sites that are built using the Commerce templates. |
|
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
Last updated