Dhruv Gupta1
Kilo Sage
Kilo Sage

Definitions:

The Syntax Editor(SE) is a ServiceNow built-in text editor. It offers the following features as you script:

  • Automatic Javascript syntax coloring, auto-indentation, line numbers, and creation of closing braces and quotes.
  • Code Editing functions
  • Context-sensitive Help
  • Syntax Error Checking
  • Editor Macros for typing commonly used code

Color Coding:

As a developer, we understand the importance of color-coding. It enhances the code reading experience. So, in SE we have following color codes:

  • Blue for strings or reserved keywords(can't choose it as a variable name)
  • Purple for Javascript commands(tells the platform what to do)
  • Green comments(Comments help you or other people understand code better)
  • Bold text indicates the context menu item.find_real_file.png

See the color codes in the example.

 

Braces and Quotes:

As we type the code in SE, the closing parenthesis, braces or quote are automatically inserted and you can also check the matching character while placing the cursor beside the parenthesis, braces or quote.

find_real_file.png

 

Context-Sensitive Help

While editing a script, Context-Sensitive Help can be invoked by using the CTRL+ Space (both Mac/Windows) or a .(period)

 

find_real_file.png

 

Note: Suggestions are context-sensitive relative to the cursor's current position and are filtered based on API type. So if you are working on a server-side script like BR you will see suggestions from server-side APIs only.

Properties assigned to a locally declared object are also included in the suggestions for example:

If I have an object called car that has attributes like the model, capacity, make, so when I type car. I will get the attributes in the suggestion.

Context Menu Options:

In the syntax editor, bold font is used for tokens that have a context menu. Right-click the token to view context menu options. If you use a Mac, you can use the Command-click shortcut.

find_real_file.png

Code Editing Functions:

SE toolbar provides standard JavaScript code editing functions:

find_real_file.png

find_real_file.png

Just explore each one of them and trust me once you are habitual of using these tricks you will certainly have better efficiency.

REQUEST:

If you find the article helpful, please mark the article as helpful, and since it has lots of useful links do remember to bookmark this article.

In case you need any help, please do connect with me. It will be my pleasure to help you.

 

 Happy Learning Guys!!!

----->Dhruv Gupta

 

 

Comments
Amrit Preet Sin
Giga Contributor

Great Article 

Shoaib5
Giga Contributor

Informative 🙂

Shaun18
Giga Contributor

ANother great article. Bro you are doing some amazing stuffs

Qamber Ali
Tera Contributor

Excellent article. Thank you.

Version history
Last update:
‎04-30-2020 11:47 PM
Updated by: