New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

ServiceNow CAD Exam - Topic 2 Question 100 Discussion

Actual exam question for ServiceNow's CAD exam
Question #: 100
Topic #: 2
[All CAD Questions]

In a privately-scoped application, which methods are used for logging messages in server-side scripts? (Choose 2 answers)

Show Suggested Answer Hide Answer
Suggested Answer: A, D

Understanding Scoped Applications:Scoped applications in ServiceNow are designed to isolate and protect application-specific code and data. Server-side scripts within scoped applications can use the gs (GlideSystem) object for logging and debugging purposes. However, not all gs methods are appropriate or valid for scoped applications.

Valid Logging Methods in Scoped Applications:

gs.info():This method logs informational messages to the system log. It is commonly used for general-purpose logging when developers need to track execution flow or display debug data. Example:

gs.info('This is an informational log message.');

gs.error():This method logs error messages to the system log. It is used to indicate problems or issues encountered during script execution. Example:

gs.error('An error occurred during script execution.');

Incorrect Options Explained:

gs.debug() (Option B): This method is not valid in scoped applications. It is a legacy logging method available in the global scope but restricted in scoped applications.

gs.iog() (Option C): This is a typographical error and not a valid gs method in ServiceNow.

gs.logError() (Option E): This is not a recognized ServiceNow API method. To log errors, gs.error() is used instead.

Best Practices for Logging:

Logging should be meaningful and avoid unnecessary entries to keep logs clean and manageable.

Avoid excessive use of logging in production environments, as it can clutter the system logs and potentially degrade performance.

ServiceNow Developer Documentation on GlideSystem (gs).

SN Pro Tips on debugging and logging practices in scoped applications.


Contribute your Thoughts:

0/2000 characters
Nan
17 days ago
I think B and E are also valid.
upvoted 0 times
...
Stephaine
22 days ago
Logging? I just use console.log() and hope for the best. Who needs fancy server-side logging anyway?
upvoted 0 times
...
Annita
27 days ago
Hmm, I was torn between B) gs.error() and C) gs.debug(), but I suppose those aren't the right choices here.
upvoted 0 times
...
Lai
1 month ago
Wait, there's no option for "gs.printToConsole()"? What is this, amateur hour?
upvoted 0 times
...
Donte
1 month ago
I thought D) gs.logError() was the way to go, but I guess I was mistaken.
upvoted 0 times
...
Kami
1 month ago
A) gs.log() and E) gs.info() are the correct answers.
upvoted 0 times
...
Candida
2 months ago
I believe gs.debug() is also used for logging, but I can't recall if it's the best choice for this question.
upvoted 0 times
...
Fernanda
2 months ago
I’m a bit confused about gs.logError()—is that a valid method? I feel like I’ve seen it somewhere.
upvoted 0 times
...
Desmond
2 months ago
I remember practicing a question like this, and I think gs.error() is definitely one of the methods we should choose.
upvoted 0 times
...
Suzan
2 months ago
Hmm, I think gs.debug() and gs.logError() sound like they could be valid options too. I'm going to review the logging documentation to make sure I have a solid understanding of all the available methods.
upvoted 0 times
...
Mattie
2 months ago
The key here is that the question is asking about a privately-scoped application, so I'm guessing the more generic logging methods like console.log() wouldn't apply. I'll focus on the gs.* methods listed.
upvoted 0 times
...
Rashida
2 months ago
I'm a little confused by this question. Are there any other logging methods I should be aware of besides the ones listed? I want to make sure I don't miss anything.
upvoted 0 times
...
Elke
3 months ago
I think gs.log() and gs.info() are the main ones for general logging, but I'm not completely sure.
upvoted 0 times
...
Hubert
3 months ago
A and C are the ones!
upvoted 0 times
...
Laila
3 months ago
I think it's A and B.
upvoted 0 times
...
Virgilio
3 months ago
I remember using gs.error() a lot.
upvoted 0 times
...
Lavelle
4 months ago
Okay, I remember learning about these logging methods in class. I'm pretty confident that gs.log() and gs.info() are the two correct answers here.
upvoted 0 times
...
Sheron
4 months ago
Hmm, I think I've seen the gs.log() and gs.error() methods used for logging before, but I'm not sure about the others. I'll need to review my notes on server-side scripting.
upvoted 0 times
Marget
3 months ago
Reviewing notes is a good idea! I need to brush up too.
upvoted 0 times
...
...

Save Cancel