What is gs.info()?

Jacky Nguyen
Kilo Contributor

Hi Experts,

I have the questions about gs.info()?

  1. what is gs.info()?
  2. When to use gs.info()?
  3. when not to use gs.info()?
  4. Why we should use gs.info()?
  5. Best practice of coding gs.info()?

That is all question of me. Please explain it to help me.

Best regards,

 

 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

points below

  1. what is gs.info()? -it is used for logging messages to system logs
  2. When to use gs.info()? - it is widely used to debug the server side script in ServiceNow and mostly added to check script ran till which point
  3. when not to use gs.info()? - it should not be used in production instance; adding gs.info() for debugging is fine but remember to remove that before moving to production as it might lead to unnecessary system logs in production instance
  4. Why we should use gs.info()? - same as point 2
  5. Best practice of coding gs.info()? - refer below link

Technical Best Practices

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Could you please let me know if I use gs.info('info 1'); in script include then will I be able to see this in console that we get in browser dev tools?

The SN Nerd
Giga Sage
Giga Sage

Most ServiceNow API is documented in the Server Global Reference API.

You can do your own self-paced exercises to learn about API here.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Hi Paul,

Looks like you were wrong.
GlideSystem doesn't specify how to use gs.info() and doesn't explain it either.

I very much appreciate you giving me the answer.

 

Thanks,

 

Nowhere in my response did I say that gs.info was in that API list.

I was merely giving you the tools to find it yourself, which you still weren't able to do.

It is in the Server Scoped API.

Most products have API documentation that is only a google search away. 

The concept of debugging is explained in the first link doing a google search.

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Revanth Karra
Tera Expert

Dear Jacky Nguyen,

 

@Jacky Nguyen , hope you're doing great!

 

1. What is gs.info? 

gs.info is a function in ServiceNow that is used to log informational messages to the system logs. It is similar to the console.log function in JavaScript.

 

2. When to use gs.info?

gs.info can be used to log messages at any point in a script. However, it is typically used to log messages that are helpful for debugging or troubleshooting. For example, you could use gs.info to log the values of variables, the results of calculations, or the status of a process.

 

3. When not to use gs.info?

gs.info should not be used to log messages that are not helpful for debugging or troubleshooting. For example, you should not use gs.info to log messages that are simply informative or that do not provide any value for debugging or troubleshooting.

 

4. Why we should use gs.info?

gs.info is a valuable tool for debugging and troubleshooting ServiceNow scripts. By logging messages to the system logs, you can track the progress of your script and identify any errors or problems.

 

5. Best practice of coding gs.info?

When coding gs.info, it is important to be specific and concise. Your messages should be clear and easy to understand. You should also avoid logging excessive amounts of information, as this can make the system logs difficult to read and troubleshoot.

 

Kindly, please mark my solution as Helpful/Correct, if applicable.

 

Thanks & Regards, 

Revanth. K

Product Test Automation Engineer