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
ChermaduraiChermadurai 

Display Message According to Profile

Hi..my reqirement is if he is an administrator need to display ' U r Admin' else ' U r not an Admin'...

 

Is it possible???

samreet_matharu@psl.co.insamreet_matharu@psl.co.in

Could u pls specify whether u want that messsage to be displayed on vf /standard page?

ChermaduraiChermadurai

Samreet,

 

in vf only..

 

 

samreet_matharu@psl.co.insamreet_matharu@psl.co.in

In the Controller/Extension You can use the following method to query the current user profile.

String profileId= UserInfo.getProfileId();

Obtain the profile id of the current user then query the profile object like-

Profile currentUserProf= [select name from Profile where id =:profileId limit 1].

Then use a boolean variable to identify if user is admin or not.

Boolean isAdmin;

if(currentUserProf != null){

if(currentUserProf.name.equalsIgnoreCase('System Administrator'))

isAdmin = true;

else

isAdmin =false;

}

Then render a component on page like

<apex:outputLabel value="U r Admin" renderered="{!isAdmin}"/>

<apex:outputLabel value="U r not Admin" renderered="{!NOT(isAdmin)}"/>

}

ChermaduraiChermadurai

Thanks Samreet..

ChermaduraiChermadurai
Is able to change isadmin function 
 
To isProfile (string profilename) 
 
 passing the param of profile name like 
 gold partner user
 gold partner manager user