How to make all field read only after submit the form – ServiceNow

This article will show you, how can you make all fields are read only after submitting the form in service now?

first you need to check on the form that is “is this new record or existing one” to do so we have a function of g_form.isNewRecord()

 

so write a client script and select type onLoad(), you can write the line – g_form.setReadOnly(‘number’, true); here we are going to make read only to number field

Code is

function onLoad() {
if(!g_form.isNewRecord()){

g_form.setReadOnly(‘number’, true);

}
}

 

if you want to make read only all the fields on form without mentioning the name of each field in onLoad function, you can do this way

function onLoad() {
if(!g_form.isNewRecord()){

var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
debugger
g_form.setReadOnly(fields[x], true);
}

}

}

 

make all field read only service now

Updated: August 11, 2018 — 6:57 PM

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + 8 =


Tech Contents © 2016
Inline
Inline