XML 設定ファイルの要素
HTML テンプレートディレクティブ
HTML テンプレートエラー
デコレータ
@salesforce モジュール
サポートされるオブジェクト
getListInfoByName
getListInfosByName
PageReference の型
getListInfoByNameリストビューのメタデータを取得するには、このワイヤアダプタを使用します。
1import { LightningElement, wire } from "lwc";
2import { getListInfoByName } from "lightning/uiListsApi";
3import ACCOUNT_OBJECT from "@salesforce/schema/Account";
4
5export default class Example extends LightningElement {
6 @wire(getListInfoByName, { objectApiName: ACCOUNT_OBJECT, listViewApiName: "AllAccounts" })
7 propertyOrFunction;
8}1GET /ui-api/list-info/${objectApiName}/${listViewApiName}「Get List View Metadata (リストビューメタデータの取得)」を参照してください。
objectApiName — (必須) サポートされているオブジェクトの API 名。listViewApiName — (必須) AllAccounts などのリストビューの API 名。propertyOrFunction — ワイヤサービスからデータのストリームを受信する非公開のプロパティまたは関数。プロパティが @wire でデコレートされている場合、結果はそのプロパティの data プロパティまたは error プロパティに返されます。関数が @wire でデコレートされている場合、結果は data プロパティと error プロパティを持つオブジェクトで返されます。data — List Infoerror — FetchResponse次のコード例では、API 参照名で List Info を取得し、List Info の表示列のリストを反復処理します。
リストビューのメタデータを一括で取得するには、代わりに getListInfosByName を使用します。
Note
1<!-- wireListInfoByName.html -->
2<template>
3 <lightning-card title="wireListInfoByName">
4 <template lwc:if={displayColumns}>
5 <div class="slds-m-around_medium">
6 <template for:each={displayColumns} for:item="col">
7 <p key={col.fieldApiName}>{col.fieldApiName} : {col.label}</p>
8 </template>
9 </div>
10 </template>
11 </lightning-card>
12</template>1// wireListInfoByName.js
2import { LightningElement, wire } from "lwc";
3import { getListInfoByName } from "lightning/uiListsApi";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5export default class WireListInfoByName extends LightningElement {
6 error;
7 displayColumns;
8 @wire(getListInfoByName, {
9 objectApiName: ACCOUNT_OBJECT.objectApiName,
10 listViewApiName: "AllAccounts",
11 })
12 listInfo({ error, data }) {
13 if (data) {
14 this.displayColumns = data.displayColumns;
15 this.error = undefined;
16 } else if (error) {
17 this.error = error;
18 this.displayColumns = undefined;
19 }
20 }
21}関連トピック
The Japanese Summer '24 guide is now live