This is a line chart I plan to show in the Account detail page, but I am unable to pass the record Id from the page to LWC to Apex class. The LWC is used in a screen flow. In the Lightning page I pass the record Id.
JS:
import {LightningElement, wire, track, api} from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import getEstosDatos from '@salesforce/apex/BC_PuntajeActor3valores.getEstosDatos';
export default class BC_PuntajeActor3valores extends LightningElement {
@api recordId;
@track chartConfiguration;
@track data;
@wire(getEstosDatos , { recordId: "$recordId"})
WireGetEstosDatos({error, data}) {
if (error) {
this.error = error;
console.log('error => ' + JSON.stringify(error));
this.chartConfiguration = undefined;
} else if (data) {
let chartData = [];
(...)
The Apex class is
public class BC_PuntajeActor3valores {
@AuraEnabled(cacheable=true)
public static List<BC_Puntaje_semanal_actor__c> getEstosDatos(String actorId){
return BC_PuntajeActor3valores.obtenerDatosGrafico(actorId);
}
@RemoteAction
public static List<BC_Puntaje_semanal_actor__c> obtenerDatosRemotos(String actorId){
return BC_PuntajeActor3valores.obtenerDatosGrafico(actorId);
}
public static List<BC_Puntaje_semanal_actor__c> obtenerDatosGrafico(String actorId){
List<BC_Puntaje_semanal_actor__c> estosDatos = new List<BC_Puntaje_semanal_actor__c>();
idActor=id.valueof(actorId);
estosDatos = [select id, BC_Fecha__c, BC_Puntaje__c, BC_Orden__c from BC_Puntaje_semanal_actor__c where BC_Actor__c =: idActor order by BC_Orden__c];
system.debug(estosDatos);
return estosDatos;
}
}
Note that if I change the @wire
line to @wire(getEstosDatos , { recordId: "001H..."})
(it is, I tried with a specific Account) it does the trick (so I understand all the logic works, except that I'm unable to pass the record Id from the page to the LWC to the class).
Any help would be greatly appreciated!
Thx
recordId
in the flow?