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

  • are you sure, that this soql is valid? At least you need to pass parameter to count() aggregate function... – Oleksandr Berehovskyi Aug 25 '17 at 8:55
  • the query is working fine in developer console but not when it is running for community user – Debarun Sengupta Aug 25 '17 at 9:14
  • Post the exact code you are using for "when it is running for community user". – Keith C Aug 25 '17 at 11:14
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.

| improve this answer | |
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.