You need to sign in to do that
Don't have an account?
Ranjith YM
lead count
List<Lead> numberOfLeads = [select Id from Lead];
System.debug(numberOfLeads.size());
I need number of Leads but above my code is returning 0 always, please help me. thanks in advance
System.debug(numberOfLeads.size());
I need number of Leads but above my code is returning 0 always, please help me. thanks in advance
Greetings to you!
Are you running these statements in test class? By default, test methods cannot see your data. You need to insert leads in a test class or use @isTest(SeeAllData=true)
Also, if you are executing it in apex class then I guess that the most possible issue is if apex runs with sharing under a restricted user.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Are you running these statements in test class? By default, test methods cannot see your data. You need to insert leads in a test class or use @isTest(SeeAllData=true)
Also, if you are executing it in apex class then I guess that the most possible issue is if apex runs with sharing under a restricted user.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Hi Ranjith
Greetings to you!
I have tried your code in my org and it is working fine. So please check the leads in your org manually or post complete code to find the issue.
List<Lead> numberOfLeads = [select Id from Lead];
System.debug(numberOfLeads.size());
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com