- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:07 AM
I need either a Business rule or UI policy that will allow me to cause a field to become read only unless you have a specific role. I tried using a script from SN but so far I have not gotten it to work. The script was in a business role.
functiononLoad();{
var incidentState = g_form.getValue('incident_state');
if( incidentState =='6'|| incidentState =='7'){
g_form.setReadonly('priority',true);}}
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 07:18 AM
And also for write access to a particular role. create a write acl like below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 07:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 11:40 AM
Glad it all got resolved for you!
Take care!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:44 AM
g_form, g_user, g_etc is client side, and gs.etc is server side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 09:01 AM
Here is a good example of a simple OOtB ServiceNow onLoad Client Script called "Make applies to readonly"
function onLoad() {
//Type appropriate comment here, and begin script below
if(!g_user.hasRole('catalog_admin') && (g_user.hasRole('catalog_manager')||g_user.hasRole('catalog_editor')))
g_form.setReadOnly('applies_to',true);
}
You will need to set "Table" to Incident table in Client Script.
Then substitute your "values";
function onLoad() {
if(g_user.hasRole('role_here'))
g_form.setReadOnly('your_field',true);
}
It will not be Read-Only if the field is available on a List, if that is case use an ACL as suggested above.
Ken