I am trying to query the user table from a controller called by a lightning component in Communities.

User usr = [SELECT Id, Name, Email, Phone FROM User WHERE Id IN (Select OwnerId From Account Where Id = :u.AccountId) LIMIT 1];

Running this from a community user it returns 0 rows. My sharing settings on the user record are private but the controller is using the without sharing notation. If I my self run that query I get the expected result.

return [SELECT Id, Name, Profile.Name, AccountId, Manager.Name, Manager.Email,ContactId FROM User WHERE Id =:UserInfo.getUserId()];

This query works. Is there some weird sharing setting that I am missing?

Basically I just want to be able to query the user table from a community user and can't.

  • Sharing keyword does not work with customer community login license..can you confirm what is license type of community user – Ayub Jan 8 at 5:16
  • I have same doubt, cannot access the user object's field in soql for community user, even though proper permissions are maintained. Following is my query: select id, Designation__c, lookupuserobj__r.Id from childobject where Id =:someId – Pankaj Andhale Jan 8 at 11:31
  • Ayub do you have a link to the documentation that points this out? Its a PartnerCommunityLogin1ML license. – joshii Jan 8 at 17:50

Right now this is an issue with the Spring19 release.


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.