Sunday, December 5, 2021

How to get Id from URL in LWC

This post explains how to get Id from URL in LWC.

getParametersFromURL.html :

<template>
    <div class="slds-p-around_medium lgc-bg">
            <lightning-input type="text" label="Url " value={urlIddisabled="true"></lightning-input>
    </div>
</template>


getParametersFromURL.js :

import { LightningElement, track} from 'lwc';
export default class getParametersFromURL extends LightningElement {
    @track urlId;
    connectedCallback() {
        var urlParameters = window.location.href;
        var urlStateParameters = urlParameters.split('Opportunity/');
        var urlIDValue = urlStateParameters[1];
        urlIDValue = urlIDValue.split('/');
        this.urlId = urlIDValue[0];
    }
}



How to get Id from URL in LWC


Thanks, 
Lovesalesforceyes

No comments:

Post a Comment

Get selected radio button value in LWC

This post explains how to get selected radio button in LWC. Below is demo of output : To use the radio button in LWC you have to use the  li...