XML 設定ファイルの要素
HTML テンプレートディレクティブ
HTML テンプレートエラー
デコレータ
@salesforce モジュール
サポートされるオブジェクト
getRelatedListCount
getRelatedListInfo
getRelatedListInfoBatch
getRelatedListRecords
getRelatedListRecordsBatch
getRelatedListsInfo
PageReference の型
getRelatedListRecordsRelatedList レコードを取得するには、このワイヤアダプタを使用します。
1import { LightningElement, wire } from 'lwc';
2import { getRelatedListRecords } from 'lightning/uiRelatedListApi';
3
4export default class LdsGetRelatedListRecords extends LightningElement {
5 @wire(getRelatedListRecords, {
6 parentRecordId: '001RM000003UNu6YAG',
7 relatedListId: 'Contacts',
8 fields: ['Contact.Name','Contact.Id'],
9 sortBy: ['Contact.Name']
10 })
11}1POST /ui-api/related-list-records/${parentRecordId}/${relatedListId}「Get Related List Records with a Request Body (リクエストボディを使用した関連リストレコードの取得)」を参照してください。
parentRecordId — (必須) 関連リストを取得する必要がある親レコードの ID (取引先 ID など)。relatedListId — (必須) Contacts、Opportunities、Cases などの関連リストオブジェクトの API 参照名。fields — (省略可能) 関連リストの列項目の API 参照名。optionalFields — (省略可能) 関連リスト内の追加項目の API 参照名。pageSize — (省略可能) ページごとに返されるリストレコードの数。sortBy — (省略可能) 関連リストを並び替える基準となる項目 API 参照名の配列。1 つの要求で受け入れる値は 1 つのみです。where — (省略可能) GraphQL 構文で関連リストレコードに適用する検索条件。data — 関連リストのレコードコレクションerror — FetchResponse次のコード例では、親 ID と関連リストオブジェクトによって関連リストのレコードを取得し、レコードのリストを反復処理します。
1<!-- wireGetRelatedListRecords.html -->
2<template>
3 <lightning-card title="wireGetRelatedListRecords">
4 <template lwc:if={records}>
5 <div class="slds-m-around_medium">
6 <template for:each={records} for:item="rec">
7 <p key={rec.fields.Id.value}>{rec.fields.Name.value}</p>
8 </template>
9 </div>
10 </template>
11 </lightning-card>
12</template>1// wireGetRelatedListRecords.js
2import { LightningElement, wire } from 'lwc';
3import { getRelatedListRecords } from 'lightning/uiRelatedListApi';
4export default class WireGetRelatedListRecords extends LightningElement {
5 error;
6 records;
7 @wire(getRelatedListRecords, {
8 parentRecordId: '001RM000003UNu6YAG',
9 relatedListId: 'Contacts',
10 fields: ['Contact.Id','Contact.Name']
11 where: "{ and: [{ Name: { like: \"Bob%\" }}] }"
12 })listInfo({ error, data }) {
13 if (data) {
14 this.records = data.records;
15 this.error = undefined;
16 } else if (error) {
17 this.error = error;
18 this.records = undefined;
19 }
20 }
21}関連トピック
The Japanese Summer '24 guide is now live