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.

ui script

Rosy14
Kilo Sage

how to get the roles of logged in user in ui script. tried g_user.hasRole . not working.

3 REPLIES 3

Sohail Khilji
Kilo Patron

Can you explain your requirement and purpose ....


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Rosy14
Kilo Sage

i had added the ui script for redirecting in side ec_url_whitelist ui script of ESC portal. but this redirecting will happen only for certain role.

if (!g_user.hasRoleExactly('itil') && window.location.toString().indexOf(''XYZ'') > 0) {
    //     var url = window.location.href;
    //     url = url.replace('abc, 'pqr');
    //     window.location.assign(url);
    // }

Rosy14
Kilo Sage

Rosy14_0-1707060453634.png

here in oob ui script they have used user. how it is configured?