Hello friends, today we are going to discuss Get Record Id In Aura Component. To retrieve the record ID in a Lightning Aura Component, you can utilize the force:hasRecordId
interface. This interface allows your component to be assigned the ID of the current record. Here’s how you can implement it:
Also, check this: Get Record Id in LWC
Key Highlights :
- In your Aura component, include the
force:hasRecordId
interface. This enables your component to access the current record’s ID. - Simplified Development: Aura components offer an innate method for accessing the record Id, streamlining development without intricate setups.
- Flexibility in Customization: Developers can tailor component behavior based on the viewed record, ensuring personalized and engaging user interactions.
- Heightened Productivity: Eliminate the need for manual record Id retrieval, allowing developers to focus on feature-rich application development.
Code :
GetRecordIdInAuraComponent.html
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global"> <aura:attribute name="recordId" type="String" /> <lightning:card title="Record Id Example" iconName="standard:activation_target"> <div class="slds-m-around_medium"> <p>Record Id: {!v.recordId}</p> </div> </lightning:card> </aura:component>
GetRecordIdInAuraComponent.js
({ doInit : function(component, event, helper) { var recordId = component.get("v.recordId"); console.log("Record Id: ", recordId); } })
Output :
Reference :
What’s your Reaction?
+1
1
+1
+1
+1
+1
+1