[SalesForce] Use lightning:recordViewForm to show related record data

I am using lightning:recordViewForm with lightning:outputField in my lightning component.

Regular fields are shown correctly, but when I am trying to show a field of a related parent record nothing is shown:

<lightning:recordViewForm recordId="a1IW0000001CGSbMAO" objectApiName="Budget__c">
    <lightning:outputField fieldName="Id" />
    <lightning:outputField fieldName="Name" />
    <lightning:outputField fieldName="Grant__c" />
    <lightning:outputField fieldName="Grant__r.Id" />
</lightning:recordViewForm>

enter image description here

As you can see – fields on the Budget__c object display good, but the Id field on the parent Grant__c object, does not display at all.

Also – on chrome dev console I get this error:

Error: Field [Grant__r.Id] was not found

Is there something I am doing wrong or is that not supported?

Best Answer

I dont believe that the correct notation is Grant__r.Id check the api field name on the object ad use that instead.

form Master-detail relationships (even lookups) I dont believe what you are attempting is possible, you can only reference the field itself, not the fields of the relationship object, unlike when using the force:recordData component which uses the Lightning Data Service, versus the record:EditForm which uses the User Interface API