The below soql query is returning count as 0 always for community user profile however the same query is working for system admin profile.
[SELECT COUNT() from user where profileid=:p.id];
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityThe below soql query is returning count as 0 always for community user profile however the same query is working for system admin profile.
[SELECT COUNT() from user where profileid=:p.id];
I ran some tests here and if I try this code, it returns nothing:
[SELECT COUNT() from user where profileid=:p.id];
On the other hand, if I try this code, it run well:
[SELECT COUNT(ID) from user where profileid=:p.id];
I sure that you should indicate what is the field that you will use to aggregate.
The above issue got resolved.The issue was because the OWD of the user object was private for external sharing model which community follows and hence from community the query was not returning any result.