Making all the fields non editable except one in Client Script

aditiojha
Tera Contributor

I am making entire form read only on a condition with a on load client script with code as below :

 

var fields = g_form.getEditableFields();

for (var x = 0; x < fields.length; x++) {

        g_form.setReadOnly(fields[x], true);

}

 

This is because i have lot of conditional hide and display on form.

 

Now the requirement is to make one single field editable on that condition.

 

Can i achieve this using same client script or creating something new but keeping this Client Script.

 

When i am adding a line to make the field mandatory in same Client Script. The Client Script is not working at all.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@aditiojha 

make the field which you want to be editable once you end the for loop

var fields = g_form.getEditableFields();

for (var x = 0; x < fields.length; x++) {

        g_form.setReadOnly(fields[x], true);

}

g_form.setReadOnly('fieldName', false);

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Thanks. It worked.

Is this still a valid glideform api?  It's not on the developers reference anymore: 

https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideFormAPI#r_GlideForm-AddDe...

@kemmy1 

there are many functions which are undocumented and developers are still using it

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader