getListInfosByName

リストビューのメタデータを一括で取得するには、このワイヤアダプタを使用します。

構文 

1import { getListInfosByName } from "lightning/uiListsApi";
2import ACCOUNT_OBJECT from "@salesforce/schema/Account";
3
4export default class KeywordResults extends LightningElement {
5  @wire(getListInfosByName, {
6    names: ["${ACCOUNT_OBJECT.objectApiName}.AllAccounts"],
7  })
8  getListInfosByNameWire({ data }) {
9    if (data && data.results) {
10      this.listInfos = data.results.map(({ result }) => result);
11    }
12  }
13}

ユーザインターフェース API リソース 

1GET /ui-api/list-info/batch?names=Account.AllAccounts,Contact.AllContacts

「Get a Batch of List View Metadata (リストビューメタデータの一括取得)」を参照してください。

パラメータ 

  • names — (必須) リストビュー名のカンマ区切り文字列の配列。リストビュー名の先頭はエンティティ名であり、ドットを挟んでリストビューの名前が続くため、Account.AllAccounts のようになります。
  • propertyOrFunction — ワイヤサービスからデータのストリームを受信する非公開のプロパティまたは関数。プロパティが @wire でデコレートされている場合、結果はそのプロパティの data プロパティまたは error プロパティに返されます。関数が @wire でデコレートされている場合、結果は data プロパティと error プロパティを持つオブジェクトで返されます。

戻り値 

使用方法 

次のコード例では、API 参照名でリスト情報を取得し、リスト情報の表示列のリストを反復処理します。

1 つのリストビューのメタデータを取得するには、getListInfoByName を使用します。

Note

1<!-- wireListInfosByName.html -->
2<template>
3    <lightning-card title="wireListInfosByName">
4        <template for:each={listInfos} for:item="listInfo">           
5            <div class="slds-m-around_medium" key={listInfo.id}>
6                <header>{listInfo.listViewApiName}</header>
7                <template for:each={listInfo.displayColumns} for:item="col">
8                    <p key={col.fieldApiName}>
9                      {col.fieldApiName} : {col.label}                     
10                    </p>
11                </template>     
12            </div>
13        </template>
14    </lightning-card>
15</template>
1// wireListInfosByName.js
2import { LightningElement, wire } from "lwc";
3import { getListInfosByName } from "lightning/uiListsApi";
4import ACCOUNT_OBJECT from "@salesforce/schema/Account";
5export default class WireListInfosByName extends LightningElement {
6  listInfos;
7  @wire(getListInfosByName, {
8    names: ["${ACCOUNT_OBJECT.objectApiName}.AllAccounts"],
9  })
10  listInfo({ error, data }) {
11    if (data) {
12      this.listInfos = data.results.map(({ result }) => result);
13    }
14  }
15}

The Japanese Summer '24 guide is now live

日本語の Summer '24 ガイドが公開されました! 「Component Reference (コンポーネントリファレンス)」は、以前と同様にコンポーネントライブラリにあります。