Syntax editor JavaScript support
Summarize
Summarized using AI
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.
Summary of Syntax Editor JavaScript Support
The syntax editor in ServiceNow provides essential editing functions for JavaScript scripts, enhancing the development experience by offering tools for code formatting, syntax checking, and search capabilities. This functionality is crucial for ensuring accurate and efficient scripting within applications.
Show less
Key Features
- Toggle Syntax Editor: Enables or disables the syntax editor.
- Format Code (Access Key + R): Automatically applies proper indentation.
- Comment/Uncomment Selected Code (Access Key + C/U): Easily comment or uncomment sections of code.
- Check Syntax: Automatically checks for syntax errors as you write, highlighting issues in real-time.
- Search Functions: Options to search, find next/previous occurrences, and replace text, including support for regular expressions.
- Save Changes: Saves edits without leaving the current view.
- Toggle Full Screen Mode (Access Key + L): Expands the editor for easier coding.
- Help (Access Key + P): Displays keyboard shortcuts for quick reference.
JavaScript Editing Tips
- Use the minus/plus signs to fold/unfold code blocks.
- Indent or decrease indentation using the Tab and Shift + Tab keys.
- Insert fixed spaces anywhere in the code using the Tab key.
JavaScript Resources
Scripts adhere to the ECMA 262 standard. For further learning, consider resources like the Mozilla Developer Network, ECMA standard documentation, and JavaScript number references.
The syntax editor provides editing functions to support editing JavaScript scripts.
JavaScript editing functions
| Icon | Keyboard Shortcut | Name | Description |
|---|---|---|---|
| N/A | Toggle Syntax Editor | Disables the syntax editor. Click the button again to enable the syntax editor. | |
| Access Key + R | Format Code | Applies the proper indentation to the script. | |
| Access Key + C | Comment Selected Code | Comments out the selected code. | |
| Access Key + U | Uncomment Selected Code | Removes comment codes from the selected code. | |
| N/A | Check Syntax | Checks the code for syntax errors. By default, the system automatically checks for syntax errors as you type in a script field. If an error or warning is found, the syntax editor displays a bullet beside the script line containing the error or warning. This check occurs on all script fields. | |
| Access Key + \ | Start Searching | Highlights all occurrences of a search term in the script field and locates the first occurrence. Click the icon, then enter the search term and press Enter. You can use regular expressions enclosed in slashes to define the search term. For example, the term /a{3}/ locates aaa. | |
| Access Key + [ | Find Next | Locates the next occurrence of the current search term in the script field. Use Start Searching to change the current search term. | |
| Access Key + ] | Find Previous | Locates the previous occurrence of the current search term in the script field. Use Start Searching to change the current search term. | |
| Access Key + W | Replace | Replaces the next occurrence of a text string in the script field.
|
|
| Access Key + ; | Replace All | Replaces all occurrences of a text string in the script field.
|
|
| N/A | Save | Saves changes without leaving the current view. Use this button in full screen mode to save without returning to standard form view. | |
| Access Key + L | Toggle Full Screen Mode | Expands the script field to use the full form view for easier editing. Click the button again to return to standard form view. This feature is not available for Internet Explorer. | |
| Access Key + P | Help | Displays the keyboard shortcuts help screen. |
JavaScript editing tips
- To fold a code block, click the minus sign beside the first line of the block. The minus sign only appears beside blocks that can be folded. To unfold the code block, click the plus sign.
- To insert a fixed space anywhere in your code, press Tab.
- To indent a single line of code, click in the leading white space of the line and then press Tab.
- To indent one or more lines of code, select the code and then press Tab. To decrease the indentation, press Shift + Tab.
- To remove one tab from the start of a line of code, click in the line and press Shift + Tab.
JavaScript resources
Scripts use ECMA 262 standard JavaScript. Helpful resources include:
- Mozilla: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference
- ECMA Standard in PDF format: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
- History and overview: http://javascript.crockford.com/survey.html
- JavaScript number reference: http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference