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.

Making field read only for non admin users.

shubhamverm3478
Tera Contributor

Hi,

I want to make two fields read only for some non admin users on workspace form .

How can I achieve this with UI Policy.

6 REPLIES 6

Is there a way we can add those users sys id rather than role for UI policy script?

@shubhamverm3478 

 

Make use of below code in that case :

var userSysIDs = ['71826bf03710200044e0bfc8bcbe5d3b', '62826bf03710200044e0bfc8bcbe5df1', 'a8f98bb0eb32010045e1a5115206fe3a']; // Declare an array to store your non-admin user sys_id
var loggedinUserID = gs.getUserID(); //get current logged in user sys_id
if (userSysIDs.indexOf(loggedinUserID) != '-1') //Check if logged in user is part of the non-admin users array or not
{
    gs.print('exists'); // Modify here to perform tasks
} else {
    gs.print('not exists'); // Modify here to perform tasks
}

Please mark this response as correct and helpful if it assisted you with your question.