Hi there, is there a way to get user permission s...
# suitescript
r
Hi there, is there a way to get user permission status programatically? like, check if a user is admin or accountant?
e
Are you looking up a user? or are you trying to get the current user?
r
current user would be fine. btw, I could search by the current user id at the user table and check for it? does it make sense, or am I tripping?
e
You could do this ^ If you want to know the role that the current user is currently using, you can use the
N/runtime
module;
let user = runtime.getCurrentUser();
user.role // This gives back the role ID (3 = Admin)
user.roleId // This gives back the role name ("administrator")
m
For specific permissions, you can also do something like:
Copy code
var user = runtime.getCurrentUser();
var hasBillingSchedulePermission = user.getPermission({
    name: 'LIST_BILLINGSCHEDULE',
}) >= runtime.Permission.VIEW;
r
thank you so much @ericbirdsall and @Mike Robbins!!!