JavaScript syntax editor macros

reference brazil Updated Sep 10, 2026 1 min read r_SyntaxEditorMacros.md
Raw file servicenow.com

Script macros provide shortcuts for typing commonly used code. To insert macro text into a script field, enter the macro keyword followed by the Tab.

Syntax editor macros are defined in the Editor Macros [syntax_editor_macro] table. To create or modify a script macro, see Create a script macro for the syntax editor.

  • vargr

    • Inserts a standard GlideRecord query for a single value.

    • Output:

      JavaScript
      var gr = new GlideRecord("$0");gr.addQuery("name", "value");gr.query();if (gr.next()) {   }
  • vargror

    • Inserts a GlideRecord query for two values with an OR condition.

    • Output:

      JavaScript
      var gr = new GlideRecord('$0'); var qc = gr.addQuery('field', 'value1'); qc.addOrCondition('field', 'value2');gr.query(); while (gr.next()) {
       }
  • for

    • Inserts a standard recursive loop with an array.

    • Output:

      JavaScript
      for (var i=0; i< myArray.length; i++) { //myArray[i];
      }
  • info

    • Inserts a GlideSystem information message.

    • Output:

      JavaScript
      gs.addInfoMessage("");
  • method

    • Inserts a blank JavaScript function template.

    • Output:

      JavaScript
      /*_________________________________________________________________   * Description:   * Parameters:   * Returns:   ________________________________________________________________*/: function() {
      },
  • doc

    • Inserts a comment block for describing a function or parameters.

    • Output:

      JavaScript
      /**                 * Description:                  * Parameters:                  * Returns:*/

Parent Topic:Using the JavaScript syntax editor

Search documentation
Search document titles and file paths on the brazil branch