dave_slusher
ServiceNow Employee

In Geneva, the script editor has been given significant upgrades in functionality. As you edit scripts, you'll see a number of changes that make the developer experience smoother and more productive.

Real Time Syntax Check

One of the first things you will notice as you edit scripts is that there is now a real time syntax checker. This can be toggled on and off with a button. Rather than the manual syntax check via button or the automatic check on submitting the form, you get real time highlighting of syntax warnings and errors in you code. As you type, the bar on the left side will display line numbers as well as noting lines with syntax errors.

Screen Shot 2015-11-18 at 10.33.56.png

By hovering over the dots, you will see the text of the error message. The Javascript compilation is happening in the background as you type and giving you feedback about lines of code that need to be fixed. As you continue to type and fix the errors, you will see the indicators disappear.

Autocomplete Known Record Types

New in Geneva is autocomplete in the script editor. In any situation where the editor can determine what your object is, it will autocomplete fields and methods of that object. For example, using the Marketing Events application from the developer program training courses as an example, here is the editing of one of those business rules. After a rule has been saved (and it has to have been saved first), the editor now understands what table it is acting on so it can determine what "current" is. This rule is acting on the Marketing Event table, so typing an "e" character shows the available fields that start with that letter. The editor autocompletes functions as well, which you can note by the "F" icon to the left.

Screen Shot 2015-11-18 at 10.43.24.png

One word about the limitation of auto-complete: as of Geneva you cannot dot-walk through reference types and have them complete each one. If your record has a Reference type field, you can complete that but not the fields of the referenced type. As an example, if you try to auto-complete "sys_updated_by" on a record, you will not be able to auto-complete the fields from the sys_user table directly.

Autocomplete Any Object Type

The autocomplete doesn't end at the inferred object types. If you define an object in code, the editor will be able to auto-complete in that context. In my example, I am creating the variable named object, which contains two data fields and a function definition. If we then reference object and auto-complete, it shows the three available possibilities - the two data fields and the function. In this case, it even displays a different icon for the numeric field versus the field of string type.

You'll note that as you auto-complete on any GlideRecord type object, all the data fields have an "O" icon even if it is a String type variable or Numeric. The reason for that lies in the way GlideRecords are implemented. Although they are typed, at their heart every data field on a GlideRecord is an object of type GlideElement so that is why they register as objects and not as data fields. Any object defined by you in your scope will display the type specific icons.

Screen Shot 2015-11-18 at 12.42.34.png

Note that you can even autocomplete the GlideSystem functions just by typing "gs". Since the editor knows what type of object gs is, you see the autocomplete information as soon as you type the following dot. If you are ever in a situation where the autocomplete is not popping up but you want it, such as if you used the arrow key to navigate around, you can type Crtl-space to bring it back.

Screen Shot 2015-11-18 at 10.48.53.png

Hotkeys

That leads us into the next topic - hotkeys in the script editor as of Geneva. At any point you can click the question mark icon and it will pop up a list of the editor hotkeys.

Screen_Shot_2015-11-18_at_13_08_16-with-box.png

Since the Fuji release, almost all of the hotkey combinations have changed for the simpler. For example, in Fuji to comment code was Ctrl-Alt-C and to uncomment was Ctrl-Atl-U. As of Geneva, Cmd-/ will toggle the comment, so the single combination will add or remove a "//" style comment prefix from a single line or even a selected block.

Similarly, searching in the script editor has been simplified to Cmd-F to start searching, Cmd-G to find next and Cmd-Shift-G to find previous. This brings the keystroke combinations more in line with what developers would expect from using other similar tools. It makes the experience of authoring code in the script editor more intuitive. As with many of the Geneva enhancements to the development environment, it brings the ServiceNow platform closer to parity with the IDE style tools a desktop developer would be familiar with.

Screen Shot 2015-11-18 at 13.07.11.png

Autosave

One additional feature that is new to Geneva is autosave. As I was writing this blog post, I had a runaway Chrome page that forced me to close my whole browser window. When I returned to my business rule to continue editing, you'll notice the icon in the upper left corner. That shows that this particular application file has auto-saved data that has not been saved to the instance. Although I had not saved the example of creating the local object, even after a browser crash when I reloaded the "Calculate total cost" business rule, the edited code was inserted back into the script field. This is not a feature I expect developers to see a lot (at least I hope not) but on those occasions when it is triggered, it will be a great time saver.

Screen Shot 2015-11-18 at 12.40.21.png

As you can see, the Geneva release brings many great features to help developers get their job done faster, with less error and lower risk of losing work.

Other entries in this series:

What's New in Geneva for Developers? - the overview post

What Developers Need to Know about Geneva: Part 1 - Studio

5 Comments