I have created a custom button on the detail page of the event object and passed the record id in the URL but I'm not able to get the get that id in the LWC component as you can see in the screenshots. please guide me on this how to get the record id so that I will be able to display the event object fields to update by the user. enter image description here

enter image description here enter image description here


2 Answers 2

  1. You should be able to have record Id in recordId variable in js file. Check this Trailhead - https://trailhead.salesforce.com/content/learn/projects/lwc-build-flexible-apps/single-record . You should have


    in your js-meta.xml file. Then in js file you have @api recordId; and record Id magicaly apear there.

  2. You always can use standard js to get params from a URL - https://www.w3docs.com/snippets/javascript/how-to-get-url-parameters.html

  • Hi Andrii, thanks for your response and I already tried this way but the record id is undefined in the console log Apr 13 at 21:19
  • Have you tried both ways? JS approach too? Apr 14 at 18:23

you have to get your recordId from the url using connected callback.

new URL(url).searchParams.get('recordId');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .