7

I have a query on profile like profilename = [Select name from profile where id=:userinfo.getUserprofileid ].name Now I have a check in VF page like profilename == 'System Administrator' . this works fine if the logged in user language is english. If the user language is different then profile name will be 'System admin' in that language . So how to prevent this beahviour? Also is there any particular field in profile which I can use to identify the profile is system admin? so that I can have check on that field instead of checking for name which is causing the problem, for example I think modifyall filed is only checked for system admin.

2
  • Modify All permission is for User Record i think, its not for the profile. maybe simply use an OR condition for those two possibilities, i think there won't be any more possibilities.
    – user5078
    Jan 2, 2014 at 11:49
  • 1
    May not be an ideal solution but you can check for fields in the Profile object out of which it includes permission and for most of the orgs "PermissionsModifyAllData" will true only for System Administrators . Use such permission to validate for System Administrator Jan 2, 2014 at 11:50

1 Answer 1

8

You don't always to query in the controller for everything, some Profile fields are available in VF out of the box: {!$Profile.Name}.

This one is bit tricky because Profiles don't have DeveloperName field that can be used to identify record types for example. And we also don't have the "Custom?" checkbox exposed via API...

One idea would be to put something into the Description field (view the profile, then click "Edit properties").

Another would be

SELECT Id, Name, Description
FROM Profile
WHERE UserType = 'Standard' AND PermissionsAuthorApex = true

"Author Apex" means the "Modify All Data" and "View Setup and Configuration" are set too. This should deal with "power users" if you have any business people that need "Modify all data" (weird but then again I saw it few times) and even if you have some dedicated profiles for data integration user accounts - they probably won't need "Author Apex".

Last but not least - is profile creation day same with Org creation day would be a pretty good indication what's likely to be custom vs. standard ;)

You must log in to answer this question.

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