Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to check the user's role when logging in Service Portal Login widget

Dinh Nguyen
Kilo Sage

Hello,

I don't know how to code in Login widget for check role of user !

Example : if user have role 'itil' => login success else login false

Please someone help me !

Thank you so much

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

This is how you can check role inside server script in a widget.

Screenshot 2023-04-03 at 9.37.35 AM.png

	var userApprovalAccess = gs.hasRole("approval_admin") || (gs.hasRole("approver_user") && data.isMine);

View solution in original post

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

This is how you can check role inside server script in a widget.

Screenshot 2023-04-03 at 9.37.35 AM.png

	var userApprovalAccess = gs.hasRole("approval_admin") || (gs.hasRole("approver_user") && data.isMine);

Thanks @Sandeep Rajput , 

This solution helps to solve my problem

Glad it helped.