0

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.

LWC resultAura Result

   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));
        })
    }

Apex class

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;
}

}

2 Answers 2

2

I found the issue, it 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. thanks for help. enter image description here

1

Make sure you have added your class in Profile. If you are running from Guest User/ Without login than add ,it to Guest Experience Profile.

Or add class to Profile from which users are going log in.

Also ensure that object and FLS access has been given on that profile as well.

Hope it helps you. Happy learning

2
  • Thanks @jaiaswani actually I checked my profile is already has access to that class and also object FLS permission is also Read/write but this didn't resolve Commented Apr 30, 2023 at 16:21
  • Than check sharing setting is it private?, if yes than make sure portal user must be owner of some records. Or run your class in without sharing mode. Commented Apr 30, 2023 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .