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