ServiceNow Interview Questions: 15 Scripting Questions You Must Know

Scripting questions come up in virtually every ServiceNow technical interview above junior level. Here are the 15 questions that appear most frequently — with the answers framed the way interviewers expect to hear them.

Q1: What is GlideRecord and how do you use it?

GlideRecord is the server-side JavaScript API for interacting with the ServiceNow database. You create an instance for a table, add query conditions, call query(), then iterate results with next(). The key methods are addQuery(), addEncodedQuery(), getValue(), setValue(), insert(), update(), and deleteRecord().

Q2: What is the difference between getValue() and getDisplayValue()?

getValue() returns the raw database value — the sys_id for reference fields, the integer for choice fields. getDisplayValue() returns the human-readable value. Always use getValue() for comparisons in scripts and getDisplayValue() only for output to users.

Q3: What is a Script Include and when would you use one?

A Script Include is a reusable server-side JavaScript library. Use it when the same logic is needed in multiple Business Rules, Scheduled Jobs, or REST endpoints — centralise it in a Script Include so you maintain it in one place.

Q4: What is GlideAjax?

GlideAjax is the mechanism for calling server-side Script Includes from client-side JavaScript. The Script Include must be client callable and extend AbstractAjaxProcessor. The client uses the GlideAjax API to call it asynchronously and receive the response in a callback.

Q5: What is the difference between a Before and After Business Rule?

Before rules run before the record is saved — you can modify the current record's values and they will be included in the save. After rules run after the save — modifications require an explicit current.update() call.

Q6: What is an Async Business Rule and when should you use it?

Async rules run in a separate thread after the record saves. Use them for expensive operations (external API calls, large queries) where the user should not wait for the result.

Q7: What does setWorkflow(false) do?

It prevents Business Rules from firing when you call update() or insert(). Use it in Scheduled Jobs and batch operations to avoid side effects and improve performance.

Q8: How do you prevent a Business Rule from looping?

Looping occurs when a Business Rule calls update() on the same record, triggering itself again. Solutions: check current.operation() and only run on insert or on specific field changes, use setWorkflow(false), or add a custom field as a flag.

Q9: What is GlideAggregate?

GlideAggregate performs aggregate database functions — COUNT, SUM, AVG, MIN, MAX — at the database level without loading records into memory. Use it instead of counting with a GlideRecord loop.

Q10: What is the purpose of g_scratchpad?

g_scratchpad is a data bridge between Display Business Rules (server-side) and Client Scripts. Set values on g_scratchpad in a Display rule, then read them in Client Scripts without needing a GlideAjax call. This avoids the round-trip cost on form load.

Q11: How do you query reference fields in GlideRecord?

Dot-walk through the reference: gr.addQuery('assigned_to.department', 'IT'). For display values: gr.addQuery('assignment_group.nameLIKENetwork'). For the sys_id directly: gr.addQuery('assigned_to', sys_id_value).

Q12: What is the difference between current.update() in a Before vs After rule?

In a Before rule, current.update() triggers an additional database write and can cause a loop — avoid it unless you have a specific reason. In an After rule, current.update() is required to persist any modifications you make to current.

Q13: How do you handle errors in server-side scripts?

Use try/catch blocks and log with gs.error(). Always include meaningful context in error messages: the script name, the record number, and the exception message and stack trace.

Q14: What is an encoded query and how do you use it?

An encoded query is a compact string representation of filter conditions — the same format used in list view URLs. Use addEncodedQuery() to apply it to GlideRecord. Build them using the list view filter UI and copy query.

Q15: What happens to previous in a Business Rule for an Insert operation?

previous is an empty GlideRecord — all fields return empty values. Always check current.operation() before using previous to avoid logic errors on insert.

Additional questions that separate mid from senior candidates

Beyond the 15 core questions, senior ServiceNow developer interviews probe deeper architectural understanding. These additional questions come up frequently at senior level:

Q16: When would you use a Script Include vs a Business Rule? — Business Rules respond to specific record events (before/after save, display). Script Includes are reusable server-side libraries callable from multiple contexts. Use a Script Include when the same logic needs to run from multiple Business Rules, Scheduled Jobs, or REST endpoints — centralise it rather than duplicating it. See Script Includes guide.

Q17: What is the difference between current.update() in a Before rule vs After rule? — In a Before rule, calling current.update() causes an extra database write and can cause the rule to fire again (loop risk). In an After rule, current.update() is required to persist any field changes you make, because the record has already been saved. Never call current.update() in a Before rule unless you have a specific reason and loop protection in place. See current vs previous guide.

Q18: How do you debug a Business Rule that is not firing? — Check in order: Is the rule Active? Does the rule condition (filter) match the record being saved? Is the When field set correctly (before/after/async/display)? Is the Table field correct? Does the current user have a role that bypasses the rule? Use Session Debug > Debug Business Rules to see rule evaluation in real time. See debugging guide.

Q19: What is the purpose of the setWorkflow(false) and autoSysFields(false) methods? — setWorkflow(false) prevents Business Rules from firing when you call update() or insert(). autoSysFields(false) prevents the system from updating sys_updated_on, sys_updated_by, and sys_mod_count fields. Both are used in batch operations and Scheduled Jobs to prevent unintended side effects and improve performance. In a job that updates 2,000 records, 2,000 Business Rule evaluations per record update multiply the performance impact significantly.

Q20: How do you prevent a GlideRecord query from timing out on a large table? — Use addEncodedQuery() with the most restrictive conditions possible, use setLimit() to bound the result set, consider using GlideAggregate if you only need counts or aggregates rather than individual records, and for very large operations use a batching pattern (process N records per Scheduled Job run, track the last processed sys_id, continue from there next run).

Questions about integrations and Flow Designer

Q21: What is the difference between a Subflow and a Flow in Flow Designer? — A Flow has a trigger (record created, scheduled, etc.) and represents a complete automation process. A Subflow has no trigger — it is a reusable automation component called from within a Flow or another Subflow. Design logic you need in multiple flows as a Subflow.

Q22: How would you call an external REST API from a ServiceNow Flow? — Using a REST spoke step if IntegrationHub is licensed, referencing a Connection Alias for credentials. For custom APIs without a dedicated spoke, use the generic REST step with a Connection Alias. The Connection Alias stores credentials securely — never hardcode tokens in flow steps.

Q23: What are data pills in Flow Designer and how do they work?Data pills are variable references to data available in the current flow context — the triggering record, outputs from previous steps, and flow inputs. They are the equivalent of variables in traditional scripting but are presented as a visual picker rather than typed references. Dot-walking through reference fields works in data pills just as it does in GlideRecord.

Interview preparation strategy

The most effective interview preparation for ServiceNow scripting questions is hands-on practice, not re-reading documentation. For every concept on this list, write the code from scratch on your Personal Developer Instance. Write a Business Rule that loops and causes itself to fire again, then fix it. Write a GlideAjax call, break it intentionally by forgetting sysparm_name, then debug it. Write a GlideAggregate query and compare its performance to a GlideRecord loop on the same table. Experiential knowledge — knowing what things look like when they go wrong, not just how they work in theory — is what separates candidates who pass technical interviews from those who know the answers on paper but stumble when asked to extend or debug a pattern. Combine hands-on practice with the CAD certification study path and you will have covered the full breadth of what ServiceNow developer interviews test.

The interview performance mindset

ServiceNow technical interviews reward specific, mechanistic answers over general descriptions. "GlideRecord queries the database" is too vague. "GlideRecord loads each matching record as a Java object into application server memory, then exposes it to server-side JavaScript" demonstrates you understand what GlideRecord actually is. This level of precision — knowing what happens at the execution level, not just the API level — is what distinguishes candidates at the senior and architect level. Build it by reading the ServiceNow developer documentation deeply (not just the examples), following the community forums where edge cases are debated, and by encountering real production issues that force you to understand platform behaviour at a deeper level. The NowSpectrum CSA and CAD guides cover the breadth of topics tested at the certification level, which aligns well with what employer interviews test at junior and mid level.

Preparing your own questions for the interviewer

Strong technical interview candidates ask informed questions that demonstrate platform knowledge. Good questions to ask ServiceNow hiring managers: "What release is the production instance on, and how frequently do you upgrade?" (shows you understand release cadence and upgrade management). "What is the test environment and deployment process — do you use Update Sets, ATF, or a CI/CD pipeline?" (shows you understand change management). "What is the ratio of configuration to customisation in your implementation?" (shows you understand the technical debt implications of over-customisation). "How is performance monitoring handled — do you use Instance Scan regularly, and what are your current known performance issues?" (shows you understand operational concerns). These questions simultaneously demonstrate depth and give you real information to evaluate whether the role is a good technical fit. A shop that never upgrades, has no test environment, and has never run an Instance Scan is going to present different challenges than one with a mature DevOps practice. See the first ServiceNow job guide and admin-to-developer transition guide for more career preparation advice.

Want the complete reference?

This article is part of the NowSpectrum knowledge library. Browse all products for cheat sheets, interview prep, and deep-dive reference guides.

Browse All Products →
← Back to all posts