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
VJayVJay 

When i do soql in query editor it returns 2 record while same soql used in class not returning any record. What will be the issue?

Narender Singh(Nads)Narender Singh(Nads)
Hi,
Are you using the keyword 'with sharing' while declaring your class?
If yes then, remove that and try.

Let me know if it helps!
Pradeep SinghPradeep Singh
Hi VJay,
When you are querying the data using query editor, it will return all the records according to the query. It runs in the system context. Here sharing settings are not taken into account.

When you query data using class where with sharing keyword is used, it runs in user context. It means if the OWD is private for the sObject for which the query is written/executed, it only returns the records whose owner is the current user and the records shared with the same user.

So in your case, you have 2 records for an SObject and OWD is private and no sharing is used with the user who is running the class(with sharing).