How to restrict access to a field in the incident form?

Bill11
Kilo Expert

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);}}

1 ACCEPTED SOLUTION

And also for write access to a particular role. create a write acl like below:

 

find_real_file.png

View solution in original post

13 REPLIES 13

And also for write access to a particular role. create a write acl like below:

 

find_real_file.png

Glad it all got resolved for you!

 

Take care!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Jason174
Tera Guru

g_form, g_user, g_etc is client side, and gs.etc is server side.

Ken24
Giga Expert

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