I need your advice. I have custom LWC for tab and record page. For tab this component show accounts list with related oportunities. For record page it should show only this account and also it should be hidden search and pagination. I made functionality for tab but don't know how to use the same lwc for record page. Can you help me?

  • Where exactly are you stuck in the process?
    – sfdcfox
    Jun 28, 2022 at 13:15
  • I don't know how to use only one account if component on record page. My LWC now show all accounts.
    – Yauheni
    Jun 28, 2022 at 13:24

1 Answer 1


In your component's class, make sure you have the following line of code:

@api recordId;

After that, you can call a wire or imperative Apex call to get just the account's records. This attribute will be null when you're not viewing a record, and it will be not-null when you are viewing a record. You can use connectedCallback to determine which method you'd like to call.

connectedCallback() {
  if(this.recordId) {
  } else {

You can read more about how to Make a Component Aware of Its Record Context and how to Call Apex Methods Imperatively.

  • I made as you advice me. Thank you. Everything works great!
    – Yauheni
    Jun 28, 2022 at 19:07

You must log in to answer this question.

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