I wish to query for parent record data (which is a lookup). How do I pass a parameter to the apex class that is not the '$recordId'
?
Apex class:
public with sharing class cc_CaseOrderController {
@AuraEnabled(cacheable=true)
public static Order getOrder(String salesOrder) {
return [SELECT Id FROM Order WHERE Id = :salesOrder];
}
}
LWC:
import { LightningElement, wire, api } from 'lwc';
import getOrder from '@salesforce/apex/cc_CaseOrderController.getOrder';
import SALES_ORDER_FIELD from '@salesforce/schema/Case.Sales_Order__c';
export default class OrderCaseViz extends LightningElement {
@api recordId;
@wire (getOrder, {salesOrder: SALES_ORDER_FIELD}) cases; // this cant be done?
}
Whats the way forward to pass the SALES_ORDER_FIELD
to my apex class and have the Order returned so I can render it on an AppPage?
SALES_ORDER_FIELD
represents the field name and not the value. Why not just send the recordId (case record ID) to the apex method and let the apex method query to find the parent order and its details?@wire(caseData, {recordId: '$recordId'}) caseinfo;
and in the querySales_Order__r.Status__c
. What would the template look like then?{caseinfo.Sales_Order__r.Status__c}
?