> 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/experience-cloud-ja/chtoriaru/general/expressions-for-lwr-sites.md).

# LWR サイト向けの式

## 概要

式を使うと、計算を行い、プロパティ値やその他のデータにアクセスして、コンポーネントの属性に渡すことができます。動的な出力には式を使用し、値を属性に割り当ててコンポーネントに渡すことができます。

式とは、1つの値に解決できるリテラル値、変数、部分式、または演算子の任意の組み合わせです。式内でメソッド呼び出しは使用できません。

式の構文は次のとおりです。 **`{!expression}`** ここで、expression はプレースホルダーです。

## データバインディング式

| 式                                 | 説明                                                   | 対応ページとコンポーネント                                                                                                                                                                                                                         |
| --------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`{!Item.field}`**               | 現在バインドされているデータのフィールドのデータを取得します。                      | データにバインドされているもの。Salesforce CMS またはレコードデータを含めることができます。                                                                                                                                                                                 |
| **`{!Item.field._rawValue}`**     | データフィールドの生の値を取得します。                                  | CRM データにバインドされているもの。                                                                                                                                                                                                                  |
| **`{!Item.field._displayValue}`** | データフィールドの書式設定済みでローカロイズされた値を取得します。                    | CRM データにバインドされているもの。                                                                                                                                                                                                                  |
| **`{!Item._detailURL}`**          | Salesforce CMS データ項目の URL を取得します。                    | CMS 詳細ページを含む、CMS 項目にバインドされているもの。                                                                                                                                                                                                      |
| **`{!Label.namespace.name}`**     | Experience Builder でラベルを指定するときに、ラベルのローカライズ済み値を定義します。 | まず、Salesforce Setup で翻訳済みのカスタムラベルを作成します。詳細は、 [カスタムラベルを翻訳する](https://help.salesforce.com/s/articleView?id=cl_translate_edit.htm\&language=en_US\&type=5)。次に、テキストフィールドを持つ任意の Experience Builder コンポーネントでラベル式を使用すると、ローカライズされたラベルを確認できます。 |

## その他の式

他の式を使用して、パラメーターをクエリしたり、サイトの正しい basePath を解決したり、式でユーザーフィールドを活用したりします。

| 式                                         | 説明                                                                                   | 対応ページとコンポーネント                                                                                                               |
| ----------------------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| **`{!Route.param}`**                      | URL からクエリパラメーターを取得します。                                                               | <ul><li>すべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul>                 |
| **`{!param}`**                            | : の後にパラメーター名が続く URL からパラメーター値を取得します。たとえば、/global-search/:term URL から {!term} を取得します。 | <ul><li>URL に動的パラメーターを含むすべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul> |
| **`{!Site.basePath}`**                    | LWR サイトの basePath に解決されます。                                                           | <ul><li>すべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul>                 |
| **`{!User.userId}`**                      | ユーザーの Salesforce ID に解決されます。                                                         | <ul><li>すべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul>                 |
| **`{!User.isGuest}`**                     | ユーザーがゲストユーザーかどうかに基づいて、TRUE または FALSE を返します。                                          | <ul><li>すべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul>                 |
| **`{!User.Record.<User sObject Field>}`** | Salesforce User オブジェクトのフィールドの値に解決されます。                                               | <ul><li>すべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul>                 |
| **`{!User.Commerce.BuyerGroups}`**        | Commerce テンプレートを使用して構築されたサイトで使用した場合、ユーザーに関連付けられた購入者グループの一覧を返します。                     | <ul><li>すべてのページ</li><li>文字列プロパティを持つ標準コンポーネントとカスタムコンポーネント</li><li>HTML エディター</li><li>リッチコンテンツエディター</li></ul>                 |

* HTML エディターまたは Rich Content Editor コンポーネントで {!param} または {!Route.param} 式を使用すると、セキュリティ上、一部の HTML 特殊文字はエスケープされるか、別の値に置き換えられます。これらの文字には <、>、および & が含まれます。
* LWR サイトは、{!CurrentUser. で始まる認証済みユーザー情報を表示する式をサポートしていません。
* ユーザーデータを含む式は、Rich Content Editor ではプレビューおよび公開済みサイトでのみ解決されます。
* User データをバインドする場合、{!User.Record.\<User sObject Field>} 式を使用して、すべての User sObject フィールドにアクセスできます。{!User.Commerce.\<Commerce Field>} 式を使用して、Commerce テンプレートを使用して構築されたサイトで Commerce に関連するユーザーデータにアクセスすることもできます。Summer ’23 リリースでは、Commerce フィールドとしてサポートされているのは BuyerGroups のみです。

### ソース

<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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
