function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
himanshu huske 7himanshu huske 7 

Apex Class does not return list of record

Working as SystemAdmin,
No triggers are active,
public class S_4_ContactListController {
   @AuraEnabled
   public static List<Contact> getContactList(){
      list<Contact> contactList = new List<Contact>([Select Id, FirstName,LastName, Email, Phone From contact Where Email != null]);  
      // contactList = [Select Id, FirstName,LastName, Email, Phone From contact Where Email != null];
     return contactList;  
    }
}

 
Danish HodaDanish Hoda
Hi Himanshu,
Not sure with your problem, but if you are having same issue with the commented code as well, please check the Field_level Security for System Admin profile.

Hope this should work :)
himanshu huske 7himanshu huske 7
Hi Danish,
query return records in query editor but when I try to execute the class method it does not show any record.
Danish HodaDanish Hoda
hi Himanshu,Please share me your js and cmp code.
SUCHARITA MONDALSUCHARITA MONDAL
Hi Danish,
Since it's @AuraEnabled therefore calling in LEX component. Please check that method name is correct(exactly same as your apex class), when your are calling it from js controller.  Also try append 'WithSharing' in your apex class for running apex code in User context. 

Share your thoughts!

Thanks,
Sucharita
Danish HodaDanish Hoda
Hi Suchitra,
Nice thoughts, but Himanshu would have gotten the error saying- No method found if the method name in JS controller were different with the one shared here.