I created a LWC for a custom object, exposed it to lightning__RecordPage and put it on the Lightning page for a related custom object. I added


to the js controller, but it's not getting populated. Then in the connected callback I set the subsidyID. In order to be sure, I added this:

        this.subsidyId = this.recordId;
        console.log('in connected callback, the record id: ', this.recordId);

and the result in the console is:

in connected callback, the record id:  undefined

Also, in the html I put the following:

 Subsidy Id: {subsidyId}

and it comes up empty.

The xml:


What could I be doing wrong?

I noticed the following warning in the docs (here: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_record_context)

IMPORTANT The recordId is set only when you place or invoke the component in an explicit record context. In all other cases, the recordId isn’t set, and your component shouldn’t depend on it.

but I don't understand what that means. What is explicit record context?


Strange - I edited the page, and in the preview the id showed. I went back to the page and it shows. Go figure.

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.