SEL_ObjectPermission
Class · Group: Selectors
global inherited sharing class SEL_ObjectPermissionProvides methods for querying and evaluating user access permissions on Salesforce objects. Simplifies permission checks by exposing operations such as read or create access for single or multiple users via PermissionSetAssignment with semi-join into ObjectPermissions.
Since: 1.0
Example:
Boolean canRead = SEL_ObjectPermission.hasReadAccess(userId, Account.SObjectType);
Boolean canCreate = SEL_ObjectPermission.hasCreateAccess(userId, Case.SObjectType);
Set<Id> readers = SEL_ObjectPermission.hasReadAccess(userIds, Account.SObjectType);Properties
| Property | Description |
|---|---|
| global enum ObjectPermissionType | A Permission that a User might have on a SObjectType. |
Methods
| Method | Description |
|---|---|
| global static Boolean hasAccess(SEL_ObjectPermission.ObjectPermissionType objectAccessLevel, Id userId, SObjectType objectType) | Checks if a specific user has the required access level for a particular SObjectType. |
| global static Set hasAccess(SEL_ObjectPermission.ObjectPermissionType objectAccessLevel, Set<Id> userIds, SObjectType objectType) | Verifies if multiple users have a specified access level for a given object type. |
| global static Boolean hasCreateAccess(Id userId, SObjectType objectType) | Checks if a specified user has create access to a particular object type. |
| global static Boolean hasReadAccess(Id userId, SObjectType objectType) | Determines if a specified user has read access to a particular Salesforce object type. |
| global static Set hasReadAccess(Set<Id> userIds, SObjectType objectType) | Checks if a set of specified users has read access to a given object type. |
Method Details
hasAccess
global static Boolean hasAccess(SEL_ObjectPermission.ObjectPermissionType objectAccessLevel, Id userId, SObjectType objectType)Checks if a specific user has the required access level for a particular SObjectType.
Parameters:
objectAccessLevel(SEL_ObjectPermission.ObjectPermissionType) - The ObjectPermissionType (e.g., CREATE, READ) to check foruserId(Id) - The Id of the user to check access forobjectType(SObjectType) - The SObjectType of the object for which access is being checked
Returns: Boolean - True if the user has the specified access level; otherwise, false
Since: 1.0
Example:
Boolean result = SEL_ObjectPermission.hasAccess(new ObjectPermissionType(), recordId, Account.SObjectType);hasAccess
global static Set<Id> hasAccess(SEL_ObjectPermission.ObjectPermissionType objectAccessLevel, Set<Id> userIds, SObjectType objectType)Verifies if multiple users have a specified access level for a given object type.
Parameters:
objectAccessLevel(SEL_ObjectPermission.ObjectPermissionType) - The ObjectPermissionType (e.g., MODIFY_ALL, VIEW_ALL) to check foruserIds(Set) - A Set of User Ids to check access forobjectType(Id) - The SObjectType of the object for which access is being checked
Returns: Id - The Ids of users that have the required access level
Since: 1.0
Example:
Set<Id> result = SEL_ObjectPermission.hasAccess(new ObjectPermissionType(), recordIds, Account.SObjectType);hasCreateAccess
global static Boolean hasCreateAccess(Id userId, SObjectType objectType)Checks if a specified user has create access to a particular object type.
Parameters:
userId(Id) - The Id of the User to check for create accessobjectType(SObjectType) - The SObjectType of the object to check access for
Returns: Boolean - True if the user has create access; otherwise, false
Since: 1.0
Example:
Boolean result = SEL_ObjectPermission.hasCreateAccess(recordId, Account.SObjectType);hasReadAccess
global static Boolean hasReadAccess(Id userId, SObjectType objectType)Determines if a specified user has read access to a particular Salesforce object type.
Parameters:
userId(Id) - The Id of the User to check for read accessobjectType(SObjectType) - The SObjectType of the object to check access for
Returns: Boolean - True if the user has read access to the object; otherwise, false
Since: 1.0
Example:
Boolean result = SEL_ObjectPermission.hasReadAccess(recordId, Account.SObjectType);hasReadAccess
global static Set<Id> hasReadAccess(Set<Id> userIds, SObjectType objectType)Checks if a set of specified users has read access to a given object type.
Parameters:
userIds(Set) - A Set of User Ids to check for read accessobjectType(Id) - The SObjectType of the object to check access for
Returns: Id - The Ids of users that have read access to the object type
Since: 1.0
Example:
Set<Id> result = SEL_ObjectPermission.hasReadAccess(recordIds, Account.SObjectType);