Scripting & APIs Questions
Master GlideRecord, GlideSystem, GlideAjax, and server-side scripting on the ServiceNow platform. Learn essential APIs for querying, updating, and managing records programmatically.
Newest question added: AI-assisted drafts, not yet individually reviewedHow questions are made
About Scripting & APIs
Server-side scripting is the core of ServiceNow application development. The platform provides powerful APIs like GlideRecord for database operations, GlideSystem for system-level utilities, and GlideAjax for client-server communication. Understanding these APIs and their proper usage is fundamental to building reliable, performant applications.
Why This Matters for Your Exam
Questions test your ability to write effective server-side scripts, use the correct API for the right situation, and understand scripting contexts. Expect questions about GlideRecord queries, GlideSystem methods, and debugging techniques.
Key Concepts to Master
Focus on GlideRecord CRUD operations (query, insert, update, delete), GlideSystem utility methods (gs.log, gs.getUser, gs.addInfoMessage), and GlideAjax for asynchronous client-server communication. Understand the difference between server-side and client-side scripting contexts.
Exam Tips
Know the difference between getValue() and getDisplayValue(). Understand addQuery(), addEncodedQuery(), and query chaining. Be familiar with GlideAggregate for counting and summing. Remember that GlideRecord scripts run on the server while g_form scripts run on the client.
Practice Questions
33 questions availableIn an after business rule, a developer must check whether the current user has the itil role before updating related records. Which call correctly uses the GlideSystem API in this server-side script?
👆 Click an option above to select your answer
Show answer and explanation
Correct answer: B. gs.hasRole('itil')
The GlideSystem API is referred to by the variable name gs in any server-side JavaScript and provides methods for information about the system and the current logged-in user. Its hasRole() method determines whether the current user has the specified role, so gs.hasRole('itil') works in a business rule.
- Why A is wrong: glide is not a variable for the GlideSystem API. Many class names start with Glide, but server-side scripts call GlideSystem methods through gs.
- Why C is wrong: g_user is the client-side GlideUser object. The docs say it is only available in client scripts and cannot be used in business rules or server-side UI actions.
- Why D is wrong: g_system is not how GlideSystem is exposed. The docs state that server-side scripts reach GlideSystem through the gs variable.
A developer writes a server-side script that must greet the logged-in user by display name, for example "Abel Tuter" rather than the login "abel.tuter". Which call returns that value?
👆 Click an option above to select your answer
Show answer and explanation
Correct answer: C. gs.getUserDisplayName()
GlideSystem getUserDisplayName() gets the display name of the current user. The docs say it returns the name field, for example Abel Tuter as opposed to abel.tuter, which is exactly the friendly name the greeting needs.
- Why A is wrong: GlideUser getID() returns the current user's sys_id, a record identifier, rather than a human-readable name.
- Why B is wrong: GlideUser getEmail() returns the user's email address, not the display name, so the greeting would show an address instead of a name.
- Why D is wrong: GlideUser getName() returns the user ID, or login name, of the current user, such as abel.tuter, not the display name.
A developer must make a field mandatory and hide another field on the Incident form when the state changes. Following ServiceNow guidance on customization versus configuration, what should they do first?
👆 Click an option above to select your answer
Show answer and explanation
Correct answer: D. Use built-in configuration tools before customizing code
ServiceNow guidance is to configure as much as you can before customizing. Configuration uses built-in tools to change behavior without altering baseline code, while customization such as scripting can add technical debt and complicate upgrades. Form changes like these fit configuration first.
- Why A is wrong: Client and server scripts are listed as customization, which can introduce technical debt and complicate upgrades. The docs say to maximize configuration before customizing.
- Why B is wrong: The docs reserve new applications for needs outside the original intent of an existing app. Changing Incident form behavior stays within ITSM, so a new app is not the first step.
- Why C is wrong: Changing baseline code is customization; such changes are flagged during upgrades and must be reviewed manually. The guidance is to prefer configuration first.