2

i am trying to display a related list in an LWC that was deployed in an AppPage

This is the code :

editMaterielAlivrer.js

import { LightningElement, wire } from 'lwc';
import { getRelatedListRecords } from 'lightning/uiRelatedListApi';


export default class EditMaterielAlivrer extends NavigationMixin(LightningElement) {

  error;
  records;

@wire(getRelatedListRecords, {
    parentRecordId: 'a0C7f000005iNUPEA2',
    relatedListId: 'Materieaux_a_livrer',
    fields : ["Materieaux_a_livrer.Id", "Materieaux_a_livrer.Oeuvre__c"]
 })


listInfo({ error, data }) {
    if (data) {
        console.log('je suis dans data');
        console.log(JSON.stringify(data));
        this.records = data.records;
        this.error = undefined;
    } else if (error) {
        console.log('je suis dans error');
        console.log(JSON.stringify(error));
        this.error = error;
        this.records = undefined;
    }
}

}

the parentRecordId is the contrat__c id , and the relatedListId is the plural label of the object Materiel_a_livrer__c

editMaterielAlivrer.html

<template>
<lightning-card title="Liste des matérieaux à livrer">
    <template if:true={records}>
        <div class="slds-m-around_medium">
            <template for:each={records} for:item="rec">
                <p key={rec.fields.Id.value}>
                    {rec.fields.Name.value}
                </p>
            </template>
        </div>
      </template>
   </lightning-card>
 </template>

editMaterielAlivrer.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
  <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  <apiVersion>55.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__AppPage</target>
    <target>lightning__RecordPage</target>
    <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>

i have created an AppPage and a button linked to the appPage

enter image description here

The button is added on the 'Matériels à livrer' relatedList on the Contrat__c object enter image description here

i want to see the related list records that are linked to the contract object on my component

it doesn't work enter image description here and i have this error in the log

{status:400,body:{message:The related lists UI API currently does not support this related list,statusCode:400,errorCode:INVALID_TYPE},headers:{},ok:false,statusText:Bad Request,errorType:fetchResponse}

any suggestions please !

FYI i am a beginner in LWC

on the relatedListId attrbute i put the plural label, it doesn't work i tried with the apiName of the object it didn't work also

2
  • check offical doc developer.salesforce.com/docs/component-library/documentation/… per doc it should be apiname of object. hence it should be api name of child object.you can try with plural and singular and check if it works Commented Jan 22, 2023 at 18:07
  • by reading your question again,i think you already tried what i wrote in previous comment. aplogies for not reading detailed question post. if you notice in your contractt lookup on child object , you will have Child Relationship Name field. can you try with that hope that will work. Commented Jan 22, 2023 at 18:17

1 Answer 1

4

In your wire method, you need to include the full api name of the object.

e.g

@wire(getRelatedListRecords, {
    parentRecordId: 'a0C7f000005iNUPEA2',
    relatedListId: 'Materieaux_a_livrer__r',
    fields : ["Materieaux_a_livrer__c.Id", "Materieaux_a_livrer__c.Oeuvre__c"]
})

I'm guessing at what the full api name is, but the relatedListId should definitely end in __r and the fields should have the __c in it, the same as any other field reference

1
  • it works thank you ! i've put the wrong relatedListId the correct one to put is the internal name of the related list ==> Materiels_livrer__r and on the html i ve updated the {rec.fields.Name.value} by <p key={rec.Id}> Commented Jan 23, 2023 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .