Make a field Read Only if value is not NULL

George P
Tera Guru

I need to make a field read only after a value has been selected.  But I need this to be affective in all views, not just on the form (e.g. List edit is also read only).  I assume this is some kind of script, but I am fairly new at scripting and could use some guidance.

1 ACCEPTED SOLUTION

Hi,

1.You can use UI policy to make any field read only if it is not empty(form View).

1.1 you can also use OnLoad Client script to make field read only

1.2 

var a= g_form.getvalue("Field");

if(a!=''")

{

//Two Variable pass as a parameter

g_form.SetReadOnly('field',true);

}

 1.3 But my suggestion you can use UI policy because it's priority is greater then Client Script.  

2.You can use ACL to make field read only.(List VIew)

Thanks,

Vikas

View solution in original post

8 REPLIES 8

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

Hi George, the list edit is normally controlled via ACL. So you need to create the 'list_edit' SCL for the required fields. See the details here:

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/list-administrati...

So I need a UI Policy for the form and this for the List; they are controlled by different methods?

In fact, you can manage the form fields visibility with ACL as well. This will be the different ACL operation, where the conditions can be defined additionally to the allowed user roles.

The UI action normally doesn't check the user roles (if there is no existing ACL for the same condition) and dynamically change the behavior the objects on a form.

Hope this makes sense.

 

 

Murthy Ch
Giga Sage

Hi George,

If it is for form u can go with client script:

Use on-change client script:

var abc= g_form.getvalue('fieldname');

if(abc!='')

{

g_form.SetReadOnly('fieldname',true);

}

 

or if it is for list :

U need to do with ACL's

 

 

Thanks,

Murthy

Thanks,
Murthy