Play Games

Search This Blog

Monday, August 8, 2016

force:recordView tag in Lightning Component

force:recordView tag is used to display a record in read-only view.
The record can be displayed in 2 different layouts.By default, the record view uses the full layout to display all fields of the record.
1) MINI -- The mini layout displays the name field and any associated parent record field.
2) FULL --displays all fields of the record.
Example :
AppToDisplayRecordView.app :
<aura:application >
    <ltng:require styles="{!$Resource.SLDS100 +
         '/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <div class="slds">
         <c:DisplayRecordView />
    </div>
</aura:application>

DisplayRecordView.cmp :
<aura:component >
<force:recordView recordId="00328000003Z3Ih" type="MINI"/>
</aura:component>
Note : "00328000003Z3Ih" is the contactId in my instance.Replace this with the contactId of the contact present in your instance.
Output:

Modify the above component to display in FULL layout.
<aura:component >
<force:recordView recordId="00328000003Z3Ih" type="FULL"/>
</aura:component>
Output: