You need to sign in to do that
Don't have an account?

IF Else Condition in APEX- Depending on user Role
I have developed a VF Component and want to do the following so was wondering if its possible and any code will be great help
So if The logged in persons Role is NOT a Programmer i want to display the following BLOCK
<apex:component controller="MyController">
<apex:pageBlock title="Products">
<apex:pageBlockTable >
</apex:pageBlockTable>
</apex:pageBlock>
and If the role is programmer i want to display a message
<div> You are not the user </div>
1) How to check the role of current logged in used in APEX
2) How to use IF Else Condition in APEX
So if The logged in persons Role is NOT a Programmer i want to display the following BLOCK
<apex:component controller="MyController">
<apex:pageBlock title="Products">
<apex:pageBlockTable >
</apex:pageBlockTable>
</apex:pageBlock>
and If the role is programmer i want to display a message
<div> You are not the user </div>
1) How to check the role of current logged in used in APEX
2) How to use IF Else Condition in APEX
All Answers
2) IF statement just like every formula field or validation rule:
This Is Controller
Replace UserRoleId With Your Programmer Id.
This Is Vf Page
Regards
Gopal Rathore