How to make Readonly to True/False Field?

m_servicenow
Kilo Contributor

Hi,

I am trying to make readonly from client script but still it can be edit. Can anybody give idea how we can do that?

 

I am using.. g_form.setReadonly('<Filed_name>',true);

We can make string filed to readonly easily but some difficulties in true/false filed.   Suggest any idea.

8 REPLIES 8

Hi Mukesh,



Can you please explain what is the exact requirement so that we can come up with best solution.



Thanks


Pradeep Sharma


harikrish_v
Mega Guru

Hi Mukesh,



I am guessing that you might have written multiple codes for the same field eg: g_form.setReadOnly('test', true) and in some other client script g_form.setReadOnly('test',false) or maybe multiple UI policy actions like this.



You can turn on the debug option and see what is exactly happening to your field.



Hope this helps..



Regards,


Hari


Subhajit1
Giga Guru

I also think that what Vijayan has said is correct.


You might have some other Client scripts or UI policy that is setting this field as Read Only False.



You might need to revisit that CS or UIP.


If it is absolutely necessary to retain that part of the code in a CS to be retained, you should change the Order in which these 2 scripts execute


Jacob_Andersen
ServiceNow Employee
ServiceNow Employee

Mukesh,



Take a quick look at the following wiki article: Differences Among Scripts - ServiceNow Enterprise Wiki . I think you need to understand this before choosing how you make fields readonly.



Workflow will not make use of client side JS and is not what you're looking for.   Typically, you want to do this with ACLs (secures it on the server side) or UI policies (client side).   I don't often need to do us using a client script.