0

Lightning:recordForm doesnt work, recordid is passed correctly but no field data is being displayed. PFB my code for lightning component:

<aura:component implements="force:lightningQuickAction,force:hasRecordId,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome" controller="OpportunityMachineViewController">  

    <aura:attribute name="sObjectInfo" type="Opportunity"/>

    <aura:attribute name="fieldsArray" type="List" default="[FirstName,LastName]"/>
    <aura:attribute name="recordId" type="String"/>  
    {!v.recordId}

<lightning:recordForm recordId="{!v.recordId}" objectApiName="Opportunity"

mode="readonly" fields="{!v.fieldsArray}"/>

</aura:component>
3
  • How are you setting {!v.recordId}?
    – Robs
    Commented May 14, 2019 at 8:07
  • I have not written anything in controller yet. Component code has been posted in question. When im printing V.recordId on component it's being set correctly.
    – Priya
    Commented May 14, 2019 at 8:11
  • My mistake you are setting recordId using force:hasRecordId. I suspect the issue is caused by a delay in the recordID value being set. Try hardcoding the recordID and you'll find it works, if this is the case, you will need to force a refresh
    – Robs
    Commented May 14, 2019 at 8:15

1 Answer 1

1

Tried below and it works:

    <aura:attribute name="sObjectInfo" type="Opportunity"/>

    <aura:attribute name="fieldsArray" type="List" default="['Name','Description']"/>
    <aura:attribute name="recordId" type="String" default="00641000007Tx2gAAC"/>  

    <lightning:recordForm recordId="{!v.recordId}" objectApiName="Opportunity"

                          mode="readonly" fields="{!v.fieldsArray}"/>

</aura:component>

Potential Failure Points:

  1. fieldsarray - check if those fields exist in opportunity object and syntax

2.Check if the running user has access to opportunity

1
  • Thanks a Lot! It worked with the change in fieldsArray
    – Priya
    Commented May 14, 2019 at 9:26

You must log in to answer this question.

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