Skip to content

SEL_UserRole

Class · Group: Selectors

apex
global inherited sharing class SEL_UserRole extends SEL_Base

Extends: SEL_Base

Selector for the UserRole SObject. Provides query methods for retrieving user roles and traversing the role hierarchy.

Example

apex
UserRole role = (UserRole)new SEL_UserRole().findById(roleId);
List<UserRole> childRoles = new SEL_UserRole().findAllChildRoles(new Set<Id>{parentRoleId});

See Also: SEL_Base


Methods

MethodDescription
global List<UserRole> findAllChildRoles(Set<Id> parentRoleIds)Recursively finds all child roles (direct and indirect descendants) for the given parent role Ids.
global override List<SObjectField> getFields()Returns the core fields for UserRole queries.

findAllChildRoles

apex
global List<UserRole> findAllChildRoles(Set<Id> parentRoleIds)

Recursively finds all child roles (direct and indirect descendants) for the given parent role Ids. Useful for determining the full role hierarchy beneath one or more starting roles.

Parameters

ParameterTypeDescription
parentRoleIdsSetSet of starting parent UserRole Ids

Returns UserRole — List of all descendant UserRole records (excluding the original parent roles)

Example

apex
List<UserRole> result = instance.findAllChildRoles(recordIds);

getFields

apex
global override List<SObjectField> getFields()

Returns the core fields for UserRole queries.

Returns SObjectField — List of UserRole SObjectField tokens

Example

apex
List<SObjectField> result = instance.getFields();

Constructors

ConstructorDescription
global SEL_UserRole()Constructs a UserRole selector.

SEL_UserRole()

apex
global SEL_UserRole()

Constructs a UserRole selector.

Example

apex
SEL_UserRole instance = new SEL_UserRole();