Get Record Id RecordId in LWC

import { LightningElement, track, wire, api } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';

export default class InternalUserOrderScreen extends NavigationMixin(LightningElement) {
@wire(CurrentPageReference) currentPageReference;

connectedCallback() {
        this.recordId = this.currentPageReference.attributes.recordId;
        setTimeout(() => {
                this.getOrderDetail();
                this.geOrdProducts();
                this.callPortDis();
                this.callForportOfLoading();
                this.getShippingModeOptionsRec();
                this.getShippingLinerOptionsRec();
                this.getMetadataIncoTermsData();
        }, 1000);
    }



--------------------------------------------

import { LightningElement, api, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import updateLeadRecord from '@salesforce/apex/LeadUpdateController.updateLeadRecord';
import { CloseActionScreenEvent } from 'lightning/actions';

import { CurrentPageReference } from 'lightning/navigation';

export default class QuickUpdateLead extends LightningElement {
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
        if (currentPageReference) {
            this.recordId = currentPageReference.state.recordId;
        }
    }
    @api recordId;
    renderedCallback() {
        const urlSearchParams = new URLSearchParams(window.location.search);
        this.recordId = urlSearchParams.get('recordId');
        //alert(this.recordId);
        if (this.recordId) {
            console.log('Found recordId: ' + this.recordId);
            // do something
            this.updateLead();
        }
    }

Comments

Popular posts from this blog

Custom List View Button In Salesforce

PDF LWC (Link for pdf liabrary)