role
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2023 04:43 AM
how to get role of current logged in user in widget ?
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2023 06:03 AM
Hello @suraj 7588
you need to write a server script and call that variable into HTML.
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user', gs.getUserID());
gr.query();
while(gr.next())
{
var role = gr.role; //Will give the sys_id of the roles
}
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2023 07:01 AM
Hi,
You can get the role JSON using below code-
var roleJSON={
"roleName":[],
"roleSysID":[]
}
var role= new GlideRecord('sys_user_has_role');
role.addQuery('user', gs.getUserID());
role.query();
while(role.next())
{
roleJSON.roleName.push(role.role.name+"")
roleJSON.roleSysID.push(role.role+"");
}
gs.info(JSON.stringify(roleJSON))
Thanks and Regards,
Saurabh Gupta