Service Now Code Snippets for VS Code

johansec
Tera Guru

Hey Guys,

I am new to service now scripting and want to make it easier. I created snippets based off of service now documentation. I use VS Code (Its Free!) to write my scripts.

To set up

  1. Download Visual Studio Code - Code Editing. Redefined
  2. Download and open the snippets file attached to this.
  3. Copy the contents.
  4. Open VS Code
  5. Navigate to File > Preferences > User Snippets
  6. Select Javascript from the dropdown
  7. Paste this over current (Unless you have existing snippets you created).
  8. Test in a new javascript file.

About This file

  • All snippets prefixed with sn_
  • Separated in main categories
    • sn_query - Basic Queries
    • sn_delete - Delete records
    • sn_insert - Insert New records
    • sn_addquery - Additional snippets to add query filters
    • sn_alert - Different alerts for client and server side scripts
    • sn_user - client and server snippets for the user object
    • sn_form - snippets for the g_form object
  • Easy to change any names by changing the prefix within the file.

Screenshot

find_real_file.png

This may not be perfect but can be a good place to start. Hope this helps someone.

5 REPLIES 5

danpatino
Tera Expert

Wow, great job @johansec.  I was just about to do this and decided to do a quick community search to find you've already done it!  Thank you for sharing.

My next target is getting the core Glide API in intellisense.  I'm pretty sure it can be done using JSDoc annotations or a Typescript declaration files but I don't know how to get the benefit without importing something before each project.  Let me know if you want to collaborate on this.

Don Stringham
Giga Contributor

@johansec thanks for doing these snippets!  @danpatino let us know when you've completed your Glide API in Intellisense!

AkshayPotdar
Kilo Contributor

I would suggest you to try an IDE like Syfer. It has options to quickly generate code code snippets for GlideRecord and GlideAjax. It also provides good intellisense options for both client and server side scripts.

It is available as free app on ServiceNow app store.

Mohit34
Kilo Contributor

Syfer studio has intellisense on custom script includes and GlideRecord

 

 

 

intellisense on tablename when we write GlideRecord

intellisense on column name

Not just shows columns of the GlideRecord table, it shows intellisense on dotwalk