Class that contains methods to retrieve SObject Permissions for a specific user. Useful in Custom VisualForce Pages to create maintainable rendered condition. It uses a Singleton pattern to avoid query repeating.
- Returns: the instance of ObjectPermissionHandler with the current user set
- Returns: the instance of ObjectPermissionHandler
- Parameters:
objectAPIName
— the API name of the objectpermission
— which kind of permission we are checking. Accepted values are 'create','read','edit','delete','view all','modify all'.
- Returns: return true if the specified user has the specified permission for that object
-
Returns: The map is intended to be used on two step: 1. Choose object 2. Choose permission type.
Pay attention: both object name and permission type are case sensitive!
accepted value for permission type are 'create','read','edit','delete','view all','modify all'.
-
Example:
ObjectPermissionHandler objPermissionHandler = ObjectPermissionHandler.getInstance();
Map<String,Map<String,Boolean>> userPermissionMap = objPermissionHandler.getUserPermissionMap();
System.assertEquals(false, userPermissionMap.get('Account').get('view all'));