You need to sign in to do that
Don't have an account?
this query is working fine get the account result in Query Editor and Anonymous Window but not getting any result from apex class
List<Account> accountList = [SELECT Id,Name From Account]; System.debug('result'+accountList); this query is working fine get the account result in Query Editor and Anonymous Window but not getting any result from apex class can you please help on this
Try below code to print.
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards
Sandhya
public without sharing class YourClassName
I tried without sharing also but not able to get the account list.
@TestVisible
static void countContacts(){
List<Account> accountList = [SELECT Id,Name From Account];
System.debug('Result'+accountList);
if(accountList.size()>0){
Account account= accountList.get(0);
account.Number_of_Contacts__c = String.valueOf('1');
update account;
}
}
}
If its a Private and User dnt have view all access on account object then it will not return all the data .. Only you can able to get the data that is having access
Login in as Runing user and create a record and then see you are getting the result or not