4

Is there a way to programmatically figure out whether a certain custom permission is enabled in User profile?

The problem that I'm trying to solve – is that I need some kind of a flag for a small subset of User profiles that would allow me to build some logic on top of. Let's say, I have a visualforce page, and I want to manage visibility to certain visualforce components on this page, such that the users who have a profile with that flag will not see those components.

1 Answer 1

5

It might make more sense to use a Hierarchy Custom Setting, which allows you to use the $Setup global variable. Note that you will get the most specific applicable instance, which is either for the whole Organization, a Profile, or a specific User.

$Setup.MyHierarchySetting__c.SomeField__c

You can also access if the running user has a specific Custom Permission using the $Permission global variable.

$Permission.MyCustomPermission

I've used both of the above to great effect, and both are pretty easy to work with.

1
  • Thank you so much, @adrian-larson, this is the information I was looking for
    – wintermute
    Jul 26, 2016 at 23:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .