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
Behzad Bahadori 18Behzad Bahadori 18 

UserInfo.getUserId() returns Null for Community User

We have this query now SELECT Id, Contact.AccountId, Contact.Account.Name FROM User WHERE Id = : UserInfo.getUserId() 
that it suppose to bring back the id and the account name of the Community User which is the Contact of an account in salesforce. but its returning Null back and the page crashes when I use it User-added imageIt seems to me that UserInfor.getUserId() is not returning a value and that is why I am getting that error . So i am trying to query the current partner community user ...Force.com and access the parent account, which it will always be the same account
Keshab AcharyaKeshab Acharya
You must login to the portal to get the user id from UserInfo.getUserId() . you are loading this page after logging in as Community user?
Dev Train 4Dev Train 4
I am having the exact same issue. Trying to build a component that loads on the homepage for a logged in partner community user. Seems to error on this code  >string user_id = UserInfo.getUserId();  < which would seem to be the problem you are experiencing. Any resolution found?
Pratikshya Satapathy 8Pratikshya Satapathy 8
Hi I am facing the same problem too. Someone please help it's urgent!!