Make field editable to only sys admins
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:21 AM
Hi,
I have created a custom field on sys_user_group table. I want only sysadmins should be able to edit that field.
I know that we can do it with ACL. But I'm not sure if this can be done with UI policy or client scripts.
Suggest me which is the best suitable method to achieve this?
If this can be done with UI policy or client scripts please provide me required script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:28 AM
Hello,
Yes you can also achieve this using Onload client script:-
Please use the below script:-
function onLoad() {
//Type appropriate comment here, and begin script below
if( g_user.hasRole('admin'))
{
g_form.setReadOnly('fieldname',false);
}
else
{
g_form.setReadOnly('fieldname',true);
}
}
Please mark answer correct/helpful based on Impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:29 AM
Hi,
Yes you can use Ui Policy and Client script to make field read-only/editable based on logged IN user role:
Please check below links for similar solutions:
you can use g_user.hasRole('admin');
But using ACL would be best solution
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:35 AM
Hi,
I would recommend using ACL at field level WRITE
onLoad client script
function onLoad() {
//Type appropriate comment here, and begin script below
if(!g_user.hasRoleExactly('admin'))
{
g_form.setReadOnly('fieldname',true);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader