Activity › Forums › Salesforce® Discussions › How to get current record id in the Salesforce lightning component?
-
How to get current record id in the Salesforce lightning component?
Posted by Shweta on May 26, 2020 at 3:42 PMHow to get current record id in the Salesforce lightning component?
Ayush replied 6 years ago 4 Members · 3 Replies -
3 Replies
-
Getting current record id in lightning web component(lwc) is very easy.
If a component with a recordId property is used on a Lightning record page, the page sets the property to the ID of the current record. In the component’s JavaScript class, use the @api decorator to create a public recordId property. Here is example of javascript class.import { LightningElement, api } from ‘lwc’;
export default class LWCExample extends LightningElement {
@api recordId;
}
To get current record id in lightning component(aura component), we had to implement force:hasRecordId to get record id in lightning aura component. But in lightning we component its very simple, we only need to use recordId property with @api decorator. - [adinserter block='9']
-
To get current record id in lightning component(aura component), we had to implement force:hasRecordId to get record id in lightning aura component. But in lightning we component its very simple, we only need to use recordId property with @api decorator.
Log In to reply.