+ Start a Discussion

get query of logined in user match with contact

Hi Team,

I am working on communities, how to get login in the user info.
I am using standard objects such as account, contact, and cases.
In under contact, we have checkbox has superuser. If it is checked login user need to able to view info of all cases associated with the account.
Id accId = [select contactid, contact.accountid from user where id = :userid].contact.accountid;
case ca = [SELECT AccountId,contact.Superuser__c ,CaseNumber,Id,Status FROM Case where status != null and contact.superuser__c = true and accountId =: accid];
Thanks for advance
Boss CoffeeBoss Coffee
You can use the following to fetch the logged in User Id.
Id uId = UserInfo.getUserId();
UserInfo documentation:
Link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_userinfo.htm)