4

I am trying to use getRelatedListRecords, it is working well with standard object, so I am getting related Contacts of Account record successfully but I cannot get related Xy Recipes records(object api name: XyRecipe__c, Tab name plural: Xy Recipes) so do I need to activate anything i Salesforce to make use of custom related list or why I am not able to use it just like Contacts list successfully? here is the code:

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

export default class Xy_recipes_lwc extends LightningElement {
    @api recordId;

   @wire(getRelatedListRecords, {
       parentRecordId: '$recordId',
       relatedListId: 'Xy Recipes',  
   }) agendaExceptionsHandler({data, error}) {
       if(data) {
           console.log('Response for getrelatedrecords: ', JSON.stringify(data));
       }

       if(error) {
           console.log('Error from getRelatedList 4: ', error);
       }
   }
}```
3
  • 3
    Solved: I had just to use child relationship name plus __r and that's it, so syntax is similar to writing subquery
    – Nikolas
    Commented Apr 11, 2022 at 12:34
  • 1
    please add it as an answer and marked as solved. (worked for me cheers)
    – Json
    Commented May 8, 2022 at 10:50
  • I am struggling with the same thing. Could you please tell me where exactly you made the change? Commented Jul 19, 2022 at 8:33

2 Answers 2

3

I was facing same issue. Adding __r fixed the issue.

@wire(getRelatedListRecords, {
    parentRecordId: '$recordId',
    relatedListId: 'Todo_List__r',
    fields: ['Todo_List__c.Id','Todo_List__c.Name']
}
-2

I have written a detailed article for the same. Please go through it and let me know if there are any open questions.

https://medium.com/@debprotim.seal/demystifying-getrelatedlistrecords-for-custom-objects-46a24cb9a80b

1
  • 2
    Welcome to Salesforce SE! While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – identigral
    Commented Oct 3, 2022 at 18:31

You must log in to answer this question.

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