IT CanvassTalk to an advisor
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');
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support