I have a problem capturing the record id from a record page in communities.

I followed Get RecordId in LWC From Community Page intructions but it's not working for me and i saw that is not working for more people.

As my LWC contains a lot of content i created a simple LWC that shows only the Record ID

ShowRecordId LWC


    <p>Record Id: {recordId}</p>


import { LightningElement, api } from 'lwc';

export default class ShowRecordId extends LightningElement {
    @api recordId;


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Record Id</masterLabel>
        <targetConfig targets="lightning__RecordPage">
            <property name="recordId" type="String" label="Record ID" description="Should be set to {!recordId}"/>            
        <targetConfig targets="lightningCommunity__Default">
            <property name="recordId" type="String" label="Record ID" description="Should be set to {!recordId}"/>            


I access to the page customer following the url

enter image description here

I added in the record page a standard record component to show that this is capturing the recordId from the context

enter image description here

Also I have seen that before publish I see an error that the record id is not being shown.

Here I just duplicated the ShowRecordId component in the Record Page

enter image description here

Error: Experience Builder can't display this component because its record ID isn't well formed. In the Propery Editor,enter a well-formed ID in the Record Id field --- for example {!recordId}.

But in this case here I put {!recordId}

enter image description here

  • Set the default value for the target property to {!recordId} instead of requiring the admin to set it manually. Please edit your question to show how the digital experience page's URL is configured. It should be something like /:recordId which is then where the variable used in the expression gets its value - the actual URL reference to the ID gets put into the variable which is then passed to the component.
    – Phil W
    Nov 29, 2023 at 11:04
  • @PhilW the question OP referenced: salesforce.stackexchange.com/questions/261178/… Specifically exists because setting the default value in the component meta file did not work at the time of writing, has that been changed?
    – gNerb
    Jan 2 at 23:12
  • David, The question you mentioned has a link to a second question I answered: salesforce.stackexchange.com/questions/261178/… which covers how the page actually populates the {!recordId} variable making it available. Have you tried /customers/0017a00002ER64LAAT /juan-cuesta?recordId=0017a00002ER64LAAT
    – gNerb
    Jan 2 at 23:16
  • 1
    @gNerb all I can say is that it works for us.
    – Phil W
    Jan 3 at 7:05
  • @PhilW Might be worth adding an answer to the original question stating that it is now supported so when new people stumble on the question they don't spend time on a solution that is no longer necessary.
    – gNerb
    Jan 9 at 20:39


You must log in to answer this question.

Browse other questions tagged .