0

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];

3
  • are you sure, that this soql is valid? At least you need to pass parameter to count() aggregate function... Aug 25, 2017 at 8:55
  • the query is working fine in developer console but not when it is running for community user Aug 25, 2017 at 9:14
  • Post the exact code you are using for "when it is running for community user".
    – Keith C
    Aug 25, 2017 at 11:14

2 Answers 2

0

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.

0
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .