ServiceNow Scripting Scenario Based Interview Questions 2026
Tip : For scripting related scenario based questions, usually interviewer asks you to login and share your PDI where you will have to write script. This way interviewer tries to understand your scripting skills.
Make sure you follow ServiceNow best practices while writing script.
e.g.
Do not use 'gr' variable name.
Give meaningful names to variables you declare.
Do not use multiple addQuery for single gliderecord instead try single 'addEncodedQuery'.
We can use GlideAggregate API to achieve this scenario:
Script :
gs.print('State\\tIncident Count');
var grIncident=new GlideAggregate('incident');
grIncident.addEncodedQuery(' sys_updated_onONToday@javascript: gs.beginningOfToday()@javascript: gs.endOfToday()');
grIncident.addAggregate('COUNT','state');
grIncident.query();
while(grIncident.next()){
gs.print(grIncident.state. getDisplayValue()+'\t'+grIncident. getAggregate('COUNT','state'));
}
Output :

Note: This scripting question is common. However, they might ask for different table or different field. The primary learning here is whenever there is question related to finding count of the records, we are supposed to use GlideAggregate API. Do not use GlideRecord API with getRowCount method, it is not considered as best practice. Also make sure you understand how addAggregate, getAggregate and groupBy works in GlideAggregate API.
We can use GlideAggregate API to achieve this scenario:
Script :
gs.print('State\\tIncident Count');
var grIncident=new GlideAggregate('incident');
grIncident.addEncodedQuery(' sys_updated_onONToday@javascript: gs.beginningOfToday()@javascript: gs.endOfToday()');
grIncident.addAggregate('COUNT','state');
grIncident.query();
while(grIncident.next()){
gs.print(grIncident.state. getDisplayValue()+'\t'+grIncident. getAggregate('COUNT','state'));
}
Output :

Note: This scripting question is common. However, they might ask for different table or different field. The primary learning here is whenever there is question related to finding count of the records, we are supposed to use GlideAggregate API. Do not use GlideRecord API with getRowCount method, it is not considered as best practice. Also make sure you understand how addAggregate, getAggregate and groupBy works in GlideAggregate API.
Script :

Output :

Note: Many of you must already be knowing how GlideRecord works but here interviewer checks if you know how setLimit, orderBy or orderByDesc can be used for such scenarios.
Script :
Output :
Note: Many of you must already be knowing how GlideRecord works but here interviewer checks if you know how setLimit, orderBy or orderByDesc can be used for such scenarios.
We need to use GlideAggregate as we need to get count of incidents. Since, we need incidents Category and sub cateory wise, we need to apply grouping on 2 fields as shown below :
Script :

Output :

Note: Take away from this scenario is to understand how grouping on multiple fields can be used. Interviewer might change question to include 3-4 grouping fields so you should understand how grouping on multiple fields can be done via GlideAggregate API. Such multiple grouping logic is also quite useful if you want to do analysis on existing data.
We need to use GlideAggregate as we need to get count of incidents. Since, we need incidents Category and sub cateory wise, we need to apply grouping on 2 fields as shown below :
Script :
Output :
Note: Take away from this scenario is to understand how grouping on multiple fields can be used. Interviewer might change question to include 3-4 grouping fields so you should understand how grouping on multiple fields can be done via GlideAggregate API. Such multiple grouping logic is also quite useful if you want to do analysis on existing data.
1. You have to create one script inlcude with two function getIncidentDetails and sendDataToBackgroundScript.
2. getIncidentDetails should fetch first incident resolved today, this function should send Incident number, assignee user, resolved date and created date to sendDatToBackgroundScript function which is in the same script include.
3. sendDataToBackgroundScript function should calculate duration between created date and resolved date and return difference and Incident Number, Assignee User.
4. sendDataToBackgroundScript shoudl be called from background script and all data should be printed.
Background Script :

Script Include :

Output :

Note: Here interviewer tries to test your basic scripting knowledge, like calling script include from another script, sending multiple values from one function to another, finding date difference, basic usage of GlideRecord with setLimit and orderBy method. Interviewer might change scenarios to introduce more ServiceNow API's so prepare yourself with these all basic scripting knowledge.
Background Script :
Script Include :
Output :
Note: Here interviewer tries to test your basic scripting knowledge, like calling script include from another script, sending multiple values from one function to another, finding date difference, basic usage of GlideRecord with setLimit and orderBy method. Interviewer might change scenarios to introduce more ServiceNow API's so prepare yourself with these all basic scripting knowledge.
There are two methods to verify users access for any glide record.
1. Use GlideRecordSecure API while creating security incident. This API implicitly verifies if user passes ACL access on table.
2. Use canRead or canWrite function. These functions implicitly verifies if logged in user satisfies ACL access.
There are two methods to verify users access for any glide record.
1. Use GlideRecordSecure API while creating security incident. This API implicitly verifies if user passes ACL access on table.
2. Use canRead or canWrite function. These functions implicitly verifies if logged in user satisfies ACL access.
Most candidates who fail weren't underskilled.
They were underprepared.
These free questions cover the basics. But interviews go deeper. Discovery, ITOM, SecOps, Flow Designer, Now Assist, AI Agents. The Job Switch Kit gives you the full 15-day roadmap, 500+ structured Q&A across every module, a LinkedIn profile optimisation guide so recruiters find you before you even apply, and an interview bot that practices with you until you're ready. Most candidates walk in under-prepared. Don't be one of them.
Battle-tested questions with structured answers across every high-frequency topic — ITOM, SecOps Vulnerability Response, Discovery, Flow Designer, AI Agents, Generative AI, and Now Assist. Plus a dedicated Behavioral round covering HR questions, STAR method answers, salary negotiation, and career direction — because technical prep alone is not enough to get the offer
Day-by-day curriculum in the right order — scripting fundamentals, ITSM & CMDB, integrations, AI modules, and behavioral prep — so you peak exactly on interview day
Two modes: system-guided sessions with curated ServiceNow questions, and self-practice where you bring your own questions. Every session is recorded — download your Q&A transcript, review your answers, and pinpoint exactly where you need to improve
Proven strategies for counter-offers, CTC decoding & in-hand salary strategy
Notice period tactics, BGV prep, resignation playbook & offer comparison
Track completion per topic, rate your confidence per question, add private notes at question level and page level. Only you see them. Always know exactly what to tackle next
Step-by-step guide to rank in recruiter searches before you apply. Module-specific keyword lists, role-based headline and About section templates, experience bullet formulas, and certification display guidance built specifically for ServiceNow professionals
🔒 Secure payment via Razorpay · Instant access after payment
Your story could be the reason someone else lands their next ServiceNow role
If this content made a real difference in your prep, sharing that experience with your network helps other professionals discover it — and we'd love to say thank you with 10 days of premium access, completely on us.
Real Interview Questions & Answers
Questions shared by ServiceNow professionals and reviewed for clarity, relevance, and interview usefulness.
Share real interview questions and help the ServiceNow community prepare better. All submissions are reviewed before publishing.
🚀 Power Up Your ServiceNow Career
Join a growing community of smart ServiceNow professionals to stay ahead in interviews, sharpen your development skills, and accelerate your career.
Login to leave a comment or feedback. Your voice helps improve the content for everyone.