IT CanvassTalk to an advisor
ServiceNow References · LessonReviewed by Praveen T, ServiceNow Trainer, 9 yrs · Updated · Published · current release · reference

ServiceNow GlideSystem (gs) API

Logging, user context and utility helpers.

Quick answer

gs is the GlideSystem object available in every ServiceNow server-side script. For logging, gs.info, gs.warn and gs.error write to the system log and gs.addInfoMessage shows a message in the UI. For context, gs.getUserName and gs.getUserID identify the user, gs.hasRole checks a role, gs.nowDateTime gives the time and gs.getProperty reads a system property.

Key takeaways
  • Logging
  • User & context

gs is the GlideSystem object, available in all server-side scripts.

Logging

  • gs.info(msg), gs.warn(msg), gs.error(msg)
  • gs.addInfoMessage(msg), show a UI message.

User & context

  • gs.getUserName(), gs.getUserID()
  • gs.hasRole(role)
  • gs.nowDateTime()
  • gs.getProperty(name)
Try it YourselfJavaScript
▸ Press Run to execute.

Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.

Practise this on your own free instance.
Set up your free instance →
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