ServiceNow Snippets · LessonReviewed by Praveen T, ServiceNow Trainer, 9 yrs · Updated · Published · current release · reference
ServiceNow Client script snippets
Form-side snippets for g_form and g_user.
Quick answer
Three client script helpers for ServiceNow forms you will reuse constantly: g_form.setMandatory('short_description', true) makes a field required, g_form.setDisplay('u_extra', false) hides one without leaving a gap, and g_form.addInfoMessage('Saved successfully') shows a message at the top of the form. Each is one line inside an onLoad, onChange or onSubmit script.
Key takeaways
- Make a field mandatory
- Hide a field
- Show a message
Browser-side helpers you reuse constantly.
Make a field mandatory
g_form.setMandatory('short_description', true);Hide a field
g_form.setDisplay('u_extra', false);Show a message
g_form.addInfoMessage('Saved successfully');