This solution does not take into account Functional Roles. If a Role has a Functional role assigned, and a user has that functional role, there is no direct link between the user and the functional role. Don't we have a SDK Creatio function for this?
If a user has an assigned functional role or an organizational role directly, this information will be stored in the "SysUserInRole" table. If it is an organizational role that has a functional role, then you need to refer to the "SysFuncRoleInOrgRole" table. The "SysAdminUnit" table contains a list of all users and roles (both organizational and functional). It has a column SysAdminUnitTypeValue, which can be used to determine the type of record. All types of records are described in the "SysAdminUnitType" table.
All these entities are available for reading data in the business process. Therefore, on the basis of one user, you can view all the roles that have been assigned directly in the "SysUserInRole" table and through organizational roles in the "SysFuncRoleInOrgRole" table.