Does the built-in code editor have syntax correction or highlighting?

jglez1
Mega Guru

Sometimes when writing code in SN, I'll mistype a variable name or function and I won't notice the error until after I test the script and it fails. It also takes a while to read through the code and find which line is the culprit.

 

I was wondering if there's syntax checking built into SN and if so how to enable it?

 

Thanks,

Jorge

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @jglez1 

Might be helpful

 

https://docs.servicenow.com/bundle/vancouver-api-reference/page/script/debugging/concept/c_ScriptSyn...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Community Alums
Not applicable

Hi @jglez1 ,

 

We have script debuger to debug the code, you can put the break points and click on script debugger and check where the issue is coming. 

SarthakKashya2_3-1713031625098.png

 

 

Many times we write same GlideRecord with same syntax so ServiceNow provide us functionlity know as Macro Editors (syntax_editor_macro) you can define some code here and you just write the keywords and you got the code.

For example : 

SarthakKashya2_0-1713031258558.png

Here we have the code for GlideRecord so in background script we just want to write vargr (Name of Macro)

and it gives the code

SarthakKashya2_1-1713031345848.png

 

SarthakKashya2_2-1713031366718.png

And we have the code for GlideRecord as we mentioned above 

 

You can check below links as well to debug your code 

https://docs.servicenow.com/bundle/vancouver-api-reference/page/script/debugging/concept/c_ScriptSyn...

https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_scripting_utah_script...

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 
Sarthak