I have a simple lightning component with a list of Orders that shows up as expected when I add it to a Lighning page in my org, but is blank when I add it to a Community/Experience Cloud page.

I've verified that the profile for the community user has access to the object and all the fields, and I've updated the metadata file to make the component available to add to community pages (I can add the component, but no data shows up).

Why would this component render data internally but not in a community?

Here's the metadata file:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">


Here's the js:

import { LightningElement,wire } from 'lwc';

/** CustomerOrdersController.getOrders Apex method */
import getOrders from '@salesforce/apex/CustomerOrdersController.getOrders';
export default class OrderList extends LightningElement {
   @wire(getOrders) orders;

Here's the HTML:

<lightning-card title="Orders">
    <div class="slds-card__body_inner">
        <!-- Start order list -->
        <template if:true={orders.data}>
            <lightning-layout multiple-rows="true" pull-to-boundary="small">
                <template for:each={orders.data} for:item="o">
                    <lightning-layout-item key={o.Id} size="3" class="slds-var-p-around_x-small">
                        <!-- Start order tile -->
                        <lightning-card title={o.Order_Id__c} >
                            <div class="slds-var-p-horizontal_small">
                                <div class="slds-media">
                                    <div class="slds-media__body">
                                        <p class="slds-var-m-bottom_xx-small">PO: {o.PoNumber}</p>
                                        <p class="slds-var-m-bottom_xx-small">Status: {o.Order_Status__c}</p>
                                        <p class="slds-var-m-bottom_xx-small">Tracking Number: {o.Tracking_Number__c}</p>
                        <!-- End order tile -->
        <!-- End order list -->
        <!-- Data failed to load -->
        <template if:true={orders.error}>
            <div class="slds-text-color_error">
                An error occurred while loading the list: {error.message} 

Here's the Apex controller:

public with sharing class CustomerOrdersController {
public static order[] getOrders() {
        return [
            FROM Order
            WHERE Type != 'Change Order' 
                AND PO_Override_by_Sales_Manager__c = False 
                AND PoNumber != null
            LIMIT 20

We need to Set Up Sharing Sets for Order objects

Set Up Sharing Sets

check the above link for more info

  • I have set up Sharing Sets for the Order object - the customer user has access to all of the records I'm trying to show. If I add a list view with the same parameters as the SOQL query, they are able to see the records, but they are not able to see them in the LWC. Mar 9 at 23:40

Found the issue. The community user profile needs to be given access to the Apex Class that is the controller.

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.