Check for multiple roles from the current logged in user

Hari1
Mega Sage

Hi,

I have a requirement to check if the user has 2 specific roles and if he has both the roles then i need to hide and display fields on the form.

How to achieve this using a client script.

Thanks.

4 REPLIES 4

anubhavkapoor76
ServiceNow Employee
ServiceNow Employee

Check this post https://community.servicenow.com/community?id=community_question&sys_id=275d92aadb1dd3004e1df4621f9619b4

 

Cheers!!

Anu

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Use this simple onload client script, Tweak code accordingly. Mark my answer as correct if that helps

function onLoad()
{
if(g_user.hasRoleExactly('name of role') && g_user.hasRoleExactly('name of role'))
{
//Show/hide Accordingly
}
}
Please hit like and mark my response as correct if that helps
Regards,
Musab

Musab Rasheed
Tera Sage
Tera Sage

Hello,

If you are fine with my reply, Please mark my reply as correct and close the thread.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Musab Rasheed
Tera Sage
Tera Sage

Hello,

If you are fine with my reply, Please mark my answer as correct and close the thread.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab