0

I Have a visualforce page where I'm having two buttons which I'm hiding to particular profiles based on profile name

rendered="{!IF($Profile.Name == 'Profile1'||$Profile.Name =='Profile2'||$Profile.Name =='Profile3', true,false)}"

Now i want to hide button for profiles and permission sets(some permission sets i need to show the button), any help would be appreciated.

1

If you are using a custom apex controller, you can just query the permission set assigned to the current user and do the verification. From there, you can choose to render the buttons or not.

List<PermissionSetAssignment> lstUserPermissionSet = [SELECT Id, PermissionSet.Name, AssigneeId                                                              
                                                     FROM PermissionSetAssignment 
                                                     WHERE AssigneeId = :Userinfo.getUserId() ];

Variable PermissionSet.Name will give you the name of the permission set.

2
  • Hi Kevan, Thanks for the prompt reply, as you suggested i have queried and getting the results of the permission set, but i have to show the button to user only with particular profile names or particular permission set. How to render permission set value on rendered. Thanks in advance Nov 6 '18 at 6:50
  • You can use the apex code UserInfo.getProfileId() to retrieve the profile id for the current user and from there, do a soql query to get the profile name. Do your logic in the controller side and assigned a boolean value to a variable which will be used to render the button. Hope this help.
    – Kevan
    Nov 7 '18 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.