0

I am using lightning-record-form and lightning-record-edit-form to display some records where I have several lookup-fields displayed, the lookup fields when rendered as output, should show the names of the parent records, but it is showing the Id.

Here is my code

<lightning-record-form record-id={recordId} columns="2" object-api-name="Custom_Object__c" fields={apiMAiFields}
    mode="read">
</lightning-record-form>

Here is the screenshot

enter image description here

I am getting the same result with lightning-record-edit-form and lightning-output-field.

PS: I have checked the access for name fields and it's enabled for the logged-in user. The same code in another sandbox working just fine.

4
  • 2
    Could this be due to the user not having sharing access to those records? Salesforce used to automatically allow the Name to be visible, even across sharing boundaries IIRC, but that did change in Spring '21 I believe.
    – Phil W
    Feb 24, 2021 at 19:20
  • @PhilW I have access to the records, when I click on the record I can go and see the record on the details page. Feb 25, 2021 at 11:09
  • This is happening to me as well in staging. In production it seems to work fine. have you figures this out? Apr 29, 2021 at 13:29
  • @LourdesMontero yes I got the answer, check below. Apr 29, 2021 at 15:22

1 Answer 1

2

These lookup fields have to be present on the Custom_Object__c page layout. The documentation for the components does mention that layout-type attribute will define what fields are available on the form, in your case the fields={apiMAiFields} attribute works in a similar fashion and will rely on the page layout for actual lookup record names, otherwise you will only see field values as links.

1
  • Thanks Liu, surprisingly, adding the field to page layout solved my problem. This is the right answer. @DavidCheng Apr 29, 2021 at 15:31

You must log in to answer this question.

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