public class Differentiating_Vfpages_Based_on_User
{
List<ApexPage> vfPageId {get;set;}
public String Userid {get;set;}
public Differentiating_Vfpages_Based_on_User()
{
Userid = UserInfo.getUserId();
if(Userid == System.Label.UserId )
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'You have no access'));
}
System.debug(System.Label.UserId);
}
}
apex page<apex:page controller ="Differentiating_Vfpages_Based_on_User">
<apex:form>
<apex:pageblock>
</apex:pageblock>
</apex:form>
</apex:page>
1 respuesta
HI Srikanth, You need to include the apex:pageMessages tag for the warning to work.Your VF code can be changed as below
<apex:page controller="Differentiating_Vfpages_Based_on_Use">
<apex:form >
<apex:pageblock >
<apex:pageMessages id="showmsg"></apex:pageMessages>
HELLO
</apex:pageblock>
</apex:form>
</apex:page>
Also, you need to make sure that the value of userid in the custom label is 18 digits. You can add a debug statement like below in your apex class to understand the values
system.debug('Userid in custom label==='+System.Label.UserId+'Userid of logged in user==='+Userid);Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you