Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Need a Catalogue Client Script To Make a Mandatory Single Text field To Read Only based on Condition

pgopinathkarthi
Tera Contributor

Need a Catalogue Client Script To Make a Mandatory Single Text field To Read Only based on Condition (True or False on a Check Box selection)

1 REPLY 1

Sonam_Tiwari
Kilo Sage

Try something like

 

var checkBoxField = g_form.getValue('check_box_field');

if (checkBoxField == 'true') {
    g_form.setMandatory('single_line_text', false);
    g_form.setReadOnly('single_line_text', true);
} else {
    g_form.setMandatory('single_line_text', true);
    g_form.setReadOnly('single_line_text', false);
}​


Why are you not using UI policies?

 

 



Consider indicating the response as helpful and marking it as correct if it meets your needs.