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