I have a problem when I used the SOQL sub query header in LWC. Initially, I wanted to show the UnitPrice from the PricebookEntries using the Product2 as base query (from). But I got a problem initializing the header in LWC.
Class:
public static List<Product2> fetchProducts(){
PriceBook2 pb2Standard =[select Id from Pricebook2 where isStandard=true limit 1];
system.debug('Pricebook ID >> ' + pb2Standard.Id);
return [select Id, Name,
,(select Product2Id, UnitPrice from PricebookEntries where Pricebook2Id = :pb2Standard.Id), Family
from Product2
where Id in (select Product2Id from PricebookEntry where Pricebook2Id =:pb2Standard.Id )
and IsActive = true and Item_Status_Name__c NOT IN ('Unclassified')];
}
LWC:
headers = {
Name:"Product Name",
PricebookEntries.UnitPrice:"UnitPrice",
Id:"ProductID"
}
May I ask for your help on showing the UnitPrice from PricebookEntries. I already tried:
PricebookEntries__r.UnitPrice:"UnitPrice"
PricebookEntries__r[0].UnitPrice:"UnitPrice"
"PricebookEntries.UnitPrice":"UnitPrice"
[PricebookEntries.UnitPrice]:"UnitPrice"
PricebookEntries(UnitPrice):"UnitPrice"
Thank you in advance!
TO show the UnitPrice from the LWC header initialization.