You need to sign in to do that
Don't have an account?
Michelle Chaplin Regal
Lightning Web Component works in Org, but not in Community
I have a lightning web component (based on the one in this trailhead module) that shows up as expected when I add it to the org homepage, but doesn't show any data when I add it to a community page. I've verified that the community user has read access to the Order object and the referenced fields.
I've updated the metadata file to make it available for Experience Cloud:
I've updated the metadata file to make it available for Experience Cloud:
<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>51.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> <target>lightningCommunity__Page</target> <target>lightningCommunity__Default</target> </targets> </LightningComponentBundle>Here's the HTML:
<template> <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> </div> </div> </div> </lightning-card> <!-- End order tile --> </lightning-layout-item> </template> </lightning-layout> </template> <!-- 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} </div> </template> </div> </lightning-card> </template>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; }And here's the Apex controller:
public with sharing class CustomerOrdersController { @AuraEnabled(Cacheable=true) public static order[] getOrders() { return [ SELECT Id, Name, Order_Id__c, PoNumber, Order_Status__c, Service_Order_Start_Date_Time__c, Product_Confirm_Date__c, Effective_Total_All_Orders__c, Tracking_Number__c FROM Order WHERE Type != 'Change Order' AND PO_Override_by_Sales_Manager__c = False AND PoNumber != null LIMIT 20 ]; } }
All Answers
Are you seeing any errors as such in the developer console and also can you mention if this is a trailhead module if so I would like to inform you that for all the Certification and Trailhead Guidance please report it here,
https://trailhead.salesforce.com/en/help?support=home
https://trailhead.salesforce.com/help
So that one of the trailhead support engineers can look into it and get back to you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.