Sub topic 13
Troubleshooting: component or properties not showing
This chapter assumes you can build a Lightning web component (LWC) with an HTML template, a JavaScript class, and a .js-meta.xml file. It also assumes you can deploy with Salesforce CLI and open Lightning App Builder in Setup. When a component is missing from App Builder, or its properties do not appear in the property panel, the cause is almost always in the metadata file or in the deployment.
Work from the outside in
Check the problem in the order the platform checks it. Each step depends on the one before it.
The component is missing from the component list
Work through these causes in order.
- The deployment failed or went to another org. Run the deploy command again and read the output. Confirm the default org with
sf org display. isExposedis missing orfalse. App Builder ignores components that are not exposed.- The target does not match the page. A component with only
lightning__RecordPagewill not appear when you edit a home page. - The
objectslist excludes the current object. A record page component limited toAccountis hidden on a Contact page. - The browser has an old copy of App Builder. Reload the builder after a deploy. Close the page and open it again if a reload does not help.
Here is a metadata file with a typical mistake. It will deploy without errors, but the component will never appear.
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<isExposed>false</isExposed>
<masterLabel>Account Summary Card</masterLabel>
<targets>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>Change the flag to true and deploy again:
sf project deploy start --source-dir force-app/main/default/lwc/accountSummaryCardThe component appears but a property does not
If the component is in the list but the property panel is empty or incomplete, check the following.
- The property is not in
targetConfigs. An@apiproperty is public in JavaScript, but admins only see it if apropertyelement lists it for the page type being edited. - The
targetsattribute does not cover the page type. In the earlier example,maxItemsis listed only forlightning__RecordPage. It will not show on an app page or home page. - The names do not match. The
nameattribute must match the JavaScript property exactly, including case.headerTextandheadertextare different. - The type is wrong. A
Stringproperty backed by a number, or anIntegerwith aminandmaxthe default value breaks, can cause deploy errors or a property that is not editable. - The value never reaches the component. If a property shows in the panel but the component ignores it, check that the JavaScript property has the
@apidecorator.
The next table maps symptoms to fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Component absent on every page | `isExposed` is `false` or the deploy failed | Set `true`, redeploy |
| Component absent on one page type | Missing target | Add the matching target |
| Component absent on one object's record page | `objects` restriction | Add the object |
| Component present, no properties | No `targetConfig` for that target | Add a `targetConfig` |
| Property missing on one page type | Property listed under other targets | Add it to that `targetConfig` |
| Property shows but has no effect | Missing `@api` or name mismatch | Fix the JavaScript property |
Check the values, not only the structure
When recordId shows as empty, the component is probably on an app or home page. Those pages have no record context. Use a record page target when you need recordId or objectApiName.
Exercise
A component deploys without errors. Its metadata lists lightning__RecordPage with an objects element containing only Account. An admin says the component is missing when she edits a Contact record page. What is the cause, and what are two ways to fix it?
Show answer
The objects element restricts the component to Account record pages, so App Builder hides it on Contact pages. Fix it by adding <object>Contact</object> to the objects list and redeploying, or by removing the objects element so the component is available on all objects.