Accessing record ID in the Lightning component is very simple. Just use following things.
- Implements force:hasRecordId interface in the component as follows.
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global">
- Define an aura:attribute as follows.
<aura:attribute name="recordId" type="String" description="The ID of the record to be displayed. Provided by force:hasRecordId interface."/>