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
rajesh_yrajesh_y 

how to get current customerportal userid

hi all

i wanna get current customerportal id 

how its possible

help me plz

 

thanks in advance

 

 

mtbclimbermtbclimber

This is not exposed in either apex or visualforce today. What's your use case and are you using a force.com site with this portal?

Pradeep_NavatarPradeep_Navatar

You can get the current customer portal user id by this code:

 

UserInfo.getUserId();

 

Below is the sample code to check whether any customer portal user is logged In or not.

User usr = [Select ContactId, Profile.Name from user where Id=: UserInfo.getUserId()];

if(usr.ContactId !=null)

{

       LoggedIn = true;

      //Customer portal user is logged in.

}

 

Hope this helps.