caller Role client scripts

saran4
Kilo Guru

How to find the role of the caller in incident form from client side

1 ACCEPTED SOLUTION

JC Icaro1
Kilo Guru

From the client-side, you will have access to the g_user object. The methods which might help you are:

- hasRole

- hasRoleExactly

 

Here's some links which might help you.

https://servicenowguru.com/scripting/user-object-cheat-sheet/

https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideUserAPI?navFilter=glideuser

 

Otherwise, you will need to do a GlideAjax call or use g_scratchpad to make it available from the server-side to the client-side.

View solution in original post

11 REPLIES 11

Gunjan Kiratkar
Kilo Patron

Hi Saran,

I'm not getting your exact requirement. Can you please elaborate more?

 

Regards,

Gunjan Kiratkar

Consultant - ServiceNow, Cloudaction

Rising Star 2022


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Do you want to fetch all the roles the caller has?

If yes then after fetching where do you want to display them?

 

 

Regards,

Gunjan Kiratkar

Consultant - ServiceNow, Cloudaction

Rising Star 2022


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

David Arbour
Tera Guru

Whether you're trying to find out if the user has a specific role or just trying to get all of the caller's roles, you'll need a GlideAjax call for this. You'll need a client-callable Script Include that searches the sys_user_has_role table for any Roles associated with the caller's sys_id. You'll then call that Script Include from a Client Script using GlideAjax and do what you would like with the values returned.

can you give me the exact script include script for this requirement.