I am having trouble getting the current record Id paramater in a LWC and passing it to an Apex method. Am I missing something? How can this be done?
LWC wire method:
@wire(getOpportunityLineItems, {oppId: this.RecordId})
contacts(result) {
this.refreshTable = result;
if (result.data) {
this.data = result.data.map(row=>{
return{...row, productName: row.Product2.Name}
})
this.error = undefined;
} else if (result.error) {
this.error = result.error;
this.data = undefined;
}
}
Apex Method with SOQL
@AuraEnabled(Cacheable = true)
public static List<OpportunityLineItem> getOpportunityLineItem(Id oppId){
return [SELECT Id, Product2Id, Product2.Name, Name, Quantity, UnitPrice, ProductCode FROM OpportunityLineItem WHERE OpportunityId= :oppId];
}