ServiceNow Developer Training

Jun 27, 2024

ServiceNow Developer Training 💻

Overview

This training program covers how to perform scripting in ServiceNow for aspiring ServiceNow developers. Topics include client scripts, UI policies, business rules, GlideAjax, workflows, event management, and more.

Key Concepts

  • Client-Side Scripting: Executed in the user's browser, used to manage forms and form fields.
  • Server-Side Scripting: Executed on the server and used to handle database operations.
  • UI Policies: Control form behavior, making fields read-only, visible, or mandatory.
  • Business Rules: Server-side scripts that run when records are displayed, inserted, deleted, or updated.
  • GlideAjax: Allows client scripts to make asynchronous calls to server-side functions or script includes.
  • Workflows: Automate sequences of activities, defined in a visual layout.
  • Event Management: Handling and responding to specific events within the ServiceNow platform.
  • Scripting in Workflows: Adding custom scripts in workflow activities for complex logic.

Client Scripts

  • Types: OnLoad, OnChange, OnSubmit, OnCellEdit.
  • Common API Methods: GlideForm (g_form), GlideUser (g_user).
  • Use Cases: Show alerts, validate form data, set field values, etc.

UI Policies

  • Purpose: Control how fields on a form are displayed (mandatory, read-only, visible).
  • Advanced Changes: Require scripting for complex conditions.

Business Rules

  • Types: Before, After, Async, Display.
  • Operations: Insert, Update, Delete, Query.
  • Global Variables: current, previous, gs (Glide System).

GlideAjax

  • Purpose: Call server-side functions from client scripts asynchronously.
  • Syntax: Create GlideAjax variable, add parameters, call server function, process response.

Workflows

  • Components: Canvas, Canvas Tabs, Palette Tabs, Title Bar.
  • Activities: Approval, Condition, Notifications, Scripting, REST Message.
  • Scripting: Add custom logic in workflow activities.

Event Management

  • Event: Point of action that triggers operations.
  • Event Registry: Define and capture events.
  • Event Processing: Use event queue, script actions, and notifications.

Practical Demos

  • Use Cases: Set field values, create approval tasks, change states, generate notifications, etc.
  • Script Includes: Classless, extending classes, utility classes.
  • GlideAjax Examples: Fetching data from server and utilizing on client side.
  • Workflows: Creating workflows with scripting for incident management.

Tools for Debugging Client Scripts

  • JavaScript Log: js_log method.
  • Field Watcher: View actions on fields.
  • Response Time Indicator: Assessing form's performance.
  • Try/Catch: Catching runtime errors.

Key API Methods and Functions

  • GlideForm: Customizing forms (e.g., addDecoration, addErrorMessage, setValue).
  • GlideRecord: Database operations (e.g., query, update, insert, delete).
  • GlideSystem (gs): System information (e.g., getUserID, getCurrentUser, log).
  • Script Includes: Server-side logic, reusable functions.

Advanced Topics

  • Scheduled Jobs: Automate repetitive server-side processes.
  • Event Management: Generating, capturing, and processing events.
  • Script Includes in Workflows: Enhancing workflows with advanced logic and scripting.

Best Practices

  • Performance Considerations: Being judicious in writing scripts and their impact on system performance.
  • Troubleshooting and Debugging: Using tools and strategies to debug scripts efficiently.
  • Code Reusability: Utilizing script includes to avoid redundant code.