User u = [SELECT Id,ContactId,Contact.AccountId FROM User WHERE Id = :UserInfo.getUserId()];

id conid=uContactId;
id acid=u.Contact.AccountId;

this are possible or not, please anybody help me

1 Answer 1


Accountid and contactid are populated if you run this as a community user /portal users .For admin Users those value are null

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