Please use docs.servicenow.com for the latest documentation.

This site is for reference purposes only and may not be accurate for the latest ServiceNow version

Syntax Editor

From Wiki Archive
Jump to: navigation, search
Note
Note: This article applies to Fuji and earlier releases. For more current information, see Syntax Editor at http://docs.servicenow.com

The ServiceNow Wiki is no longer being updated. Visit http://docs.servicenow.com for the latest product documentation.


{{Topic|Scripting Glide and Jelly

Overview

The syntax editor enables the following features for all script fields:

  • JavaScript syntax coloring, indentation, line numbers, and automatic creation of closing braces and quotes
  • Code editing functions
  • Code syntax checking
  • Script macros for common code shortcuts

This article helps administrators activate and configure the Syntax Editor plugin. To learn how to use this feature, see Using the Syntax Editor.

JavaScript syntax editor


Managing Script Macros

Script macros provide shortcuts for typing commonly used code. Several script macros are available by default. Administrators can define new or modify existing script macros.

  1. Navigate to System Definition > Syntax Editor Macros.
  2. Click New or select the macro to edit.
  3. Define the macro details with the following fields:
    • Name: shortcut that users type to use the macro.
    • Comments: description of the macro. Appears when the user types help.
    • Text: full macro text that replaces the name in the editor.
  4. [Optional] Define the the cursor position after the macro is executed by entering $0 in the macro text. For example, in the vargr macro, the cursor is placed between the quotes in the first line. The $0 is not written out as part of the macro text.

Disabling the Syntax Editor

When the syntax editor is enabled, users can choose whether to use it. This choice is stored by the glide.ui.javascript_editor user preference.

Administrators can disable the syntax editor for all users, regardless of user preference.

  1. Enter sys_properties.list in the navigation filter.
  2. Locate the glide.ui.javascript_editor property.
  3. Set the Value to false.

Configuring Syntax Checking

Administrators can configure the syntax editor to show real-time error and warning indicators beside a line of code that contains a syntax error.

  1. Enter sys_properties.list in the navigation filter.
  2. Locate the glide.ui.syntax_editor.show_warnings_errors property.
  3. Set the Value to one of the following options:
    • HIDE_ALL: hides errors and warnings (default).
    • ERRORS_ONLY: shows errors but hides warnings.
    • SHOW_ALL: shows errors and warnings.

Installed Components

Tables

The following table is added:

  • Editor Macro [syntax_editor_macro]: manages script macros, which are shortcuts for typing commonly used code. Navigate to System Definition > Syntax Editor Macros. Several script macros are added by default.

Properties

The following properties are added: