Activity Forums Salesforce® Discussions How to get current record id in the Salesforce lightning component?

  • MOHIT

    Member
    May 27, 2020 at 3:02 PM

    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.

  • Pooja

    Member
    May 27, 2020 at 3:57 PM

    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.

  • Ayush

    Member
    May 28, 2020 at 10:36 AM

    With the help of "hasRecordId" .

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Salesforce Admin Certification 2020 Questions Explained with References - Part II

Video in

How to prepare and pass Salesforce Admin Certification with Practice Exam Questions 2020 practice questions and answers for the Salesforce Administration Salesforce Certified Admin Exam Questions Salesforce Administrator Certification Exam…