Article

ServiceNow Tips and Tricks Using Syntax Macros to Simplify Writing JavaScript

ServiceNow Tips and Tricks Using Syntax Macros to Simplify Writing JavaScript

ServiceNow Tips and Tricks on using  Syntax macros to simplify writing JavaScript in ServiceNow from Milestone’s Scott Trumble, Director of ServiceNow ITX Practice.  

With a couple of keystrokes, you can automatically build common code or header blocks.

Just Type the Keyword followed by a tab.

Vargr -Inserts a standard GlideRecord query for a single value.

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

For-  Inserts a standard for loop to iterate an array.

Info – GlideSystem information message.

Method – Inserts a blank JavaScript function template.

Doc – Inserts a comment block for describing a function or a set of parameters.

For Example

Scripts Example

 

Type method and the tab

 

Global Example

Now just fill in your details.

But Wait, There’s More!

You can edit the syntax macros or create your own.

Just Go to the System Definition>> Syntax Editor Macros.

Syntax Editor Macros

As a hardcore advocate for error trapping, I like to add one to create my try-catch blocks.

I have combined them to stub out an entire function.

Editor Macro Func

Facebook
Twitter
LinkedIn
Categories

Select a Child Category
category
65d9b2373202a
0
0
34,35,36,33,38,39,37
Loading....
Recent Posts
Social Links

Related Posts

Want to Learn More?

Milestone experts take the time to listen, understand your needs, and provide the right mix of tools, technology, and resources to help you meet your goals.

Request a complimentary consultation to get started.

Request a Complimentary Consultation

Skip to content