3

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.

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.

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

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.