You need to sign in to do that
Don't have an account?
Abhishek Sharma 527
Result set not visible in LWC Experience Builder but visible on Aura App
Hello Experts, my component is fetching query result from class and showing in Aura App console but doesn't work in LWC experience builder. I tried running it on load and through button click also, it doesn't give any result, array shows blank, length 0. I tested in anonymous window this query fetches result. I don't know what I'm missing. Please guide.
import { LightningElement, track,api, wire } from 'lwc'; import getNotes from '@salesforce/apex/TBT_SupervisorNotes.getNotes'; export default class tBT_SessionGuideline extends LightningElement { @wire(getNotes) gnotes; @track getNotes; @track datalist = []; connectedCallback(){ getNotes().then(res => { this.datalist = res; console.log('hi'); console.log("result from connected callback", res); console.log("datalist result from connected callback", this.datalist); }).catch((error)=>{ console.error("error " ,JSON.stringify(error)); }) }
public class TBT_supervisorNotes { @AuraEnabled(Cacheable=true) public static List<Input_Form__c> getNotes(){ List<Input_Form__c> LognotesList = [ select id, Session_Summary__c from input_form__c where recordtype.name = 'TBT Supervisor Log Notes' ]; system.debug(LognotesList); return LognotesList; }
Try this code and let me know if you facing any difficulties :
import { LightningElement, track, wire } from 'lwc';
import getNotes from '@salesforce/apex/TBT_SupervisorNotes.getNotes';
export default class TBT_SessionGuideline extends LightningElement {
@wire(getNotes)
gnotes;
@track notesList;
@wire(getNotes)
wiredNotesList({ error, data }) {
if (data) {
this.notesList = data;
} else if (error) {
console.error(error);
}
}
}
public class TBT_supervisorNotes {
@AuraEnabled(Cacheable=true)
public static List<Input_Form__c> getNotes(){
// Query for records of the Input_Form__c object with the TBT Supervisor Log Notes record type
List<Input_Form__c> LognotesList = [SELECT Id, Session_Summary__c FROM Input_Form__c WHERE RecordType.Name = 'TBT Supervisor Log Notes'];
// Debug the results of the query
System.debug(LognotesList);
// Return the list of queried records
return LognotesList;
}
All Answers
Try this code and let me know if you facing any difficulties :
import { LightningElement, track, wire } from 'lwc';
import getNotes from '@salesforce/apex/TBT_SupervisorNotes.getNotes';
export default class TBT_SessionGuideline extends LightningElement {
@wire(getNotes)
gnotes;
@track notesList;
@wire(getNotes)
wiredNotesList({ error, data }) {
if (data) {
this.notesList = data;
} else if (error) {
console.error(error);
}
}
}
public class TBT_supervisorNotes {
@AuraEnabled(Cacheable=true)
public static List<Input_Form__c> getNotes(){
// Query for records of the Input_Form__c object with the TBT Supervisor Log Notes record type
List<Input_Form__c> LognotesList = [SELECT Id, Session_Summary__c FROM Input_Form__c WHERE RecordType.Name = 'TBT Supervisor Log Notes'];
// Debug the results of the query
System.debug(LognotesList);
// Return the list of queried records
return LognotesList;
}
I see that you also posted this ask on https://salesforce.stackexchange.com/questions/402482/result-set-not-visible-in-lwc-experience-builder-but-visible-on-aura-app according to which
" Issue was related to settings of experience builder where my object 'input form' was not added in this list of selected object so I was getting restricted from accessing those records"
Copied your solution here so that others can find it helpful in future. Please consider marking the answer as best to close the thread. Thank you