I have a detail page button on Account Detail page. I wish to open an LWC on clicking the button. The button opens a lightning tab using URL and passes a parameter along with the URL. I have an LWC on the lightning tab with utilizes that URL parameter.

Problem: The lightning tab does not get the parameter in the URL. Hence LWC does not get the parameter.

Lightning tab name: Cops_Rate_Profile_Tab

Detail page button URL: /lightning/n/Cops_Rate_Profile_Tab?MDMID={!Account.Master_Customer_ID__c}

LWC gets the URL parameter as follows:

export default class CopsRateProfileLWC extends LightningElement {


    connectedCallback() {

        //Get the MDMID from the URL
        this.MDMID = new URLSearchParams(window.location.search).get('MDMID');


I referred this website.

I am not able to find what is going wrong. Please guide. Thank You!

  • Is this on Lightning Console Tab ? – Nagendra Singh Jan 19 at 10:53
  • @NagendraSingh No. It's not on console tab. – SFdev Jan 19 at 11:55

You should use a namespace prefix for your query parameter. If the component isn’t part of a managed package you should use c__ as prefix.
So the button url would be /lightning/n/Cops_Rate_Profile_Tab?c__MDMID={!Account.Master_Customer_ID__c} and in the controller you should get c__MDMID.
Please refer to the documentation about query parameters.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.