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
Basha sk 16Basha sk 16 

Ho to Get Customer portal login user related contact and account in case deatils page when user going to create a new case?

Hi All,


Ho to Get Customer portal login user related contact and account in case deatils page when user going to create a new case?

Thanks in Advance,
Basha
NagendraNagendra (Salesforce Developers) 
Hi Basha,

Please find the below post which has been addressed from stack exchange community as below.

For the price of a SOQL query you can get a Community User's details.
Id userId = UserInfo.getUserId();
User UserDetails = [SELECT Id, username, user.ContactId, user.Contact.AccountId FROM User WHERE Id =: userId LIMIT 1];
Using the query above you could do this... Case c = new Case(); c.Contact = UserDetails.ContactId;

You just want to be careful with the results because Users that are NOT Community Users won't have Contact details and will return nulls.

Best Regards,
Nagendra.P