Retrieve Top Level RoleIds, Role Names And Below RoleIds,Role Names in Salesforce
Below code is to fetch Top Level RoleIds, Role Names And Below RoleIds,Role Names based on given user. To achieve the requirement, a batchable and a iterable have been written. here is the code for batchable class. Through this code, IC_UserRole_Hierarchy__c object record gets inserted. This object has various fields like Role Above Current User Role,Role Below Current User Role,Role Ids Above Role,Role Ids Below Role,Current User Role,Current User Role Id. When batch runs and current user value is passed then it will insert the IC_UserRole_Hierarchy__c record having all the information about above and below roles of a user. public class InvestCloudRoleHierarchyBatchable implements Database.Batchable<User>, Database.Stateful { //Implementation Batchable.Start method //Method to get the Set of Users of specified Roles public String userId {get; set;} public InvestCloudRoleHierarchyBatchable (String userId){ this.userId = userId; ...