Get role of user
Collapse
X
-
Indeed, roles are not loaded for the current user. Maybe consider using a custom field instead? It can be enum, multi-enum or link. Cannot be link-multiple as they are not loaded there. -
Hi Yuri,
I'm trying to do this too. When I create a custom view for my entity I find that this.getUser().attributes.rolesIds is undefined and when I console log it I get the attributes object (correct username, email etc) but it doesn't contain the roleIds property:
Code:"recordViews": { "detail": "custom:views/record/camera-detail" }, .................... define('custom:views/record/camera-detail', ['views/record/detail'], function (Dep) { return Dep.extend({ setup: function () { Dep.prototype.setup.call(this); console.log(`camera detail custom view `,this); // const hasRole = (this.getUser().attributes.rolesIds || []).includes(targetRoleId); console.log('role = ',this.getUser().attributes.rolesIds); // <-- undefined }, }); });
Am I doing this wrong?Last edited by onepoint0; 03-24-2025, 02:32 AM.Leave a comment:
-
Within a view:
Code:const hasRole = (this.getUser().attributes.rolesIds || []).includes(targetRoleId);
Leave a comment:
-
hi, can any one help in this ?? i also have same requirement.Leave a comment:
-
Get role of user
Hello,
How can I get if the authenticated user in the JS files and also the role?Tags: None
Leave a comment: