You need to sign in to do that
Don't have an account?
Bernardo Lira 1
Pass record Id from page to LWC to Apex class not working
Hi all.
I have a problem trying to pass the (Account) recordId from the Lightning page to an LWC to an Apex class.
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:
Apex class:
Note that if I change the
Any help would be greatly appreciated!
Thx
I have a problem trying to pass the (Account) recordId from the Lightning page to an LWC to an Apex class.
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 = []; (...)
Apex class:
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
@wireline to
@wire(getEstosDatos , { recordId: "001H..."}) // this is an actual account record Id.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
Try using this :
Hope this helps.
Thanks.
Look, I have these lines: When I swap the commented lines, like this: It works nicely (when the record Id is hardcoded).
Still in the dark here...