Scenario Based Scripting Questions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I need Scenario Based Scripting Questions including all topics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
If you have practical implementation experience and a strong understanding of fundamental scripting concepts, you should be familiar with areas such as Client Scripts, Business Rules, ACLs, Script Includes, Scheduled Jobs, and UI Actions.
From an integration perspective, you should have knowledge of JSON, JSON parsing, REST APIs, Scripted REST APIs, Integration Hub and related integration concepts.
Please follow the below threads:
https://www.servicenow.com/community/servicenow-ide-sdk-and-fluent/real-time-scenario-based-question...
https://www.servicenow.com/community/guided-learning-itsm/scenario-based-servicenow-itsm-interview-q...
https://www.servicenow.com/community/developer-articles/basic-scripting-questions-and-answers/ta-p/2...
Please mark helpful & correct answer if its worthy for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey @shirishakathula ,
This is a Interview question i prepared for my teams for the servicenow,
ServiceNow Scenario-Based Scripting Interview Questions
1. Business Rules
Beginner
Q1. A requirement says: Whenever an Incident is created, automatically populate the Assignment Group based on the Category.
- Which Business Rule type would you use?
- Would you use Before or After?
- Why?
Q2. When an Incident's Priority changes to Critical, send a notification to the Assignment Group. How would you implement this?
Q3. You need to prevent an Incident from being closed if the Resolution Notes are empty. Where would you implement this validation?
Q4. A field should automatically be populated before the record is inserted into the database. Which Business Rule type is appropriate?
Intermediate
Q5. Whenever the Assignment Group changes, you need to clear the Assigned To field. Write the Business Rule.
if (current.assignment_group.changes()) { current.assigned_to = ''; }
Why is Before Update preferable here?
Q6. You need to create a child task whenever a Change Request is created. Would you use Before or After?
Q7. A Business Rule is running twice unexpectedly. How would you troubleshoot it?
Q8. Your Business Rule is configured for Update + Priority changes, but it appears to execute when the record is created. What would you investigate?
Q9. You update a record from a Business Rule and accidentally trigger another Business Rule repeatedly. How would you prevent recursion?
2. Client Scripts
Q10.
When the Assignment Group changes on an Incident, automatically clear Assigned To.
Which Client Script type would you use?
Q11.
A field should become mandatory only when Category = Network.
Would you use:
- Client Script?
- UI Policy?
- Data Policy?
Explain why.
Q12.
You need to populate a field when the form loads based on another field.
Write an onLoad Client Script.
Q13.
You need to validate a phone number before allowing the user to submit a catalog item.
Which Client Script type?
Q14.
A user enters a value in a field and you need to retrieve information from another table before populating another field.
How would you do this?
3. GlideAjax
Q15. ⭐ Important
On an Incident form, when the user selects Caller, you need to automatically retrieve the caller's department from sys_user.
Would you query sys_user directly from a Client Script?
Why/why not?
Explain how you would implement this using:
Client Script → GlideAjax → Script Include → Response
Q16.
Write a Script Include that receives a user sys_id and returns the user's department.
Q17.
Your GlideAjax call works in the backend but returns an empty value on the client.
What would you troubleshoot?
Q18.
Why should a Script Include called through GlideAjax generally be marked Client callable?
Q19.
What is the difference between:
getXML()
and
getXMLAnswer()
4. Script Includes
Q20.
You have the same logic being used in five Business Rules.
Would you duplicate the code?
How would you improve the design?
Q21.
Create a Script Include called IncidentUtils with a function:
getCriticalIncidents()
that returns the number of active Priority 1 incidents.
Q22.
A Script Include works when called from a Business Rule but not from a Client Script.
What could be wrong?
Q23.
What is the difference between:
- Client-callable Script Include
- Server-side Script Include
Q24.
You have a complex calculation that is required by multiple Flows and Business Rules. Where would you put the logic?
5. GlideRecord
Q25. ⭐ Very Important
Find all active incidents assigned to the Network team and print their numbers.
Write the script.
Q26.
Find all incidents where:
Priority = 1
State = Open
and update their Assignment Group.
Q27.
You need to find the manager of the Incident Caller.
How would you navigate:
Incident → Caller → Manager
using GlideRecord?
Q28.
What is the difference between:
get()
and
query()
Q29.
When would you use:
addQuery()
versus:
addEncodedQuery()
Q30.
What happens if you call:
gr.update();
inside a loop containing 10,000 records?
How would you optimize it?
Q31.
You need to delete old records from a custom table. How would you safely implement this?
6. GlideAggregate
Q32. ⭐
You need to find the number of Incidents assigned to each Assignment Group.
Would you use GlideRecord or GlideAggregate?
Write the approach.
Q33.
Find the number of active Incidents for each Priority.
Q34.
Find the average resolution time for Incidents.
Why would GlideAggregate be useful?
7. ACL / Security Scripting
Q35. ⭐ Important
Users should only be able to see Incidents where they are:
- Caller
- Assigned To
- Member of Assignment Group
How would you implement this?
Q36.
A user can open a record directly using its sys_id, even though the record isn't visible in the list.
What security mechanism would you investigate?
Q37.
A user passes the table-level ACL but fails the field-level ACL.
Explain why.
Q38.
What is the difference between:
Table ACL
Field ACL
Row-level security
Q39.
You need to prevent users from modifying the salary field unless they have a specific role.
How would you implement it?
8. UI Policies
Q40.
If Incident Category = Hardware:
- Make Configuration Item mandatory
- Make it visible
- Make it editable
Would you use a Client Script or UI Policy?
Why?
Q41.
What is the difference between:
UI Policy vs Client Script?
Q42.
A UI Policy works in Core UI but not in Workspace.
What would you investigate?
9. UI Actions
Q43.
You need a "Resolve Incident" button.
When clicked:
- State → Resolved
- Resolution Code → Solved
- Resolution Notes → Mandatory
How would you implement this?
Q44.
A UI Action should only appear for users with the itil role.
How would you configure it?
Q45.
A UI Action should appear only when:
State = In Progress
AND
Assigned To = Current User
Write the condition.
Q46.
How would you hide a UI Action dynamically when a field changes?
10. GlideSystem (gs)
Q47.
What is the difference between:
gs.getUserID()gs.getUserName()gs.getUserDisplayName()
Q48.
How would you check whether the current user has a specific role?
gs.hasRole('itil')
Q49.
How would you retrieve a system property?
gs.getProperty('property.name')
Q50.
Why is using a system property better than hard-coding a sys_id?
11. GlideDateTime
Q51. ⭐
A task has a Due Date. If the Due Date is in the past, automatically move it to tomorrow.
How would you script this?
Q52.
Calculate the number of days between:
Opened
Closed
Q53.
You need to add 3 days to a GlideDateTime.
Which methods would you use?
Q54.
What is the difference between:
GlideDateTime GlideDate GlideTime
12. Catalog Client Scripts
Q55. ⭐
A catalog item has:
Requested For
Location
Department
When Requested For changes, automatically populate Location and Department.
How would you implement it?
Q56.
A catalog variable is inside an MRVS. You need to access its values from the Catalog Client Script.
How would you approach it?
Q57.
A variable should only be visible for users belonging to a particular group.
Would you use:
- Catalog UI Policy
- Catalog Client Script
- User Criteria?
Explain.
Q58.
How would you prevent a catalog item from being submitted if a variable doesn't satisfy a condition?
13. Record Producer
Q59.
A Record Producer creates an Incident.
You want:
Category → Incident.category
Short Description → Incident.short_description
Requested For → Incident.caller_id
How would you map these?
Q60.
A user selects "Yes" on a Record Producer variable. Only then should an Incident be created.
How would you implement this?
14. Catalog / RITM / SCTASK
Q61. ⭐
A catalog item creates:
REQ
└── RITM
├── SCTASK
└── SCTASK
You need to automatically close the RITM when all SCTASKs are closed.
How would you implement it?
Q62.
A Flow creates an SCTASK but the Assignment Group is empty even though the catalog variable contains the group.
How would you troubleshoot?
Q63.
You need to retrieve catalog variables from an RITM using GlideRecord.
How would you do it?
15. Flow Designer Scripting
Q64.
An OOB Flow action cannot perform the required calculation.
What would you use?
Custom Action + Script step
Explain the design.
Q65.
Create a Flow Action that receives:
Incident Sys ID
and returns:
Caller Manager
Explain the inputs, Script step and outputs.
Q66.
A Flow is repeatedly triggering itself.
How would you identify and prevent the recursion?
16. Notifications / Email Scripts
Q67. ⭐
You need to send an email containing:
Incident Number
Caller
Assignment Group
Assigned To
Short Description
How would you create the notification?
Q68.
You need to send an email to the manager of the caller.
How would you determine the recipient dynamically?
Q69.
You need to include catalog variables in an approval email.
How would you retrieve them?
Q70.
How would you use an Email Script to dynamically build HTML content?
17. Events
Q71.
A Business Rule should trigger a notification only when an Incident becomes Critical.
Would you directly send the notification from the Business Rule?
Or would you use:
gs.eventQueue()
Why?
Q72.
Explain:
gs.eventQueue( 'incident.critical', current, current.number, current.priority );
What are the parameters?
18. Scheduled Jobs
Q73. ⭐
Every night at 12 AM, find all tasks whose Due Date has passed and send a notification to the Assignment Group.
How would you implement it?
Q74.
You need to automatically close Incidents that have been resolved for more than 7 days.
Would you use:
- Business Rule
- Scheduled Script
- Flow Designer
Why?
19. Transform Maps
Q75.
You receive a CSV containing:
Employee ID
Name
Department
Manager
You need to import it into sys_user.
How would you configure the Transform Map?
Q76.
The source contains duplicate users.
How would you prevent duplicate records?
Q77.
What is the difference between:
onStart
onBefore
onAfter
onComplete
Transform Map scripts?
20. Import Sets
Q78.
An external HR system sends 10,000 employee records every night.
Design the ServiceNow import process.
Explain:
External Source
↓
Import Set
↓
Transform Map
↓
Target Table
Q79.
Some records fail during transformation.
How would you troubleshoot them?
21. REST / Integration
Q80. ⭐
You need to send an Incident from ServiceNow to an external system whenever it is created.
How would you design the integration?
Q81.
An external application needs to create Incidents in ServiceNow.
Would you use:
Inbound REST API
or
Outbound REST Message?
Explain.
Q82.
The external API requires:
Authorization: Bearer <token>
How would you securely store and use the credentials?
Q83.
An outbound REST call returns HTTP 401.
How would you troubleshoot it?
22. Scripted REST API
Q84.
Create an API:
GET /api/company/incidents/{number}
which returns:
{ "number": "INC0010001", "priority": "2", "state": "In Progress"}
How would you implement it?
Q85.
How would you secure a Scripted REST API?
23. GlideRecordSecure
Q86. ⭐
What is the difference between:
GlideRecord
and
GlideRecordSecure
When would you use each?
24. Scoped Applications
Q87.
A script works in Global but fails in a scoped application.
What would you check?
Q88.
You get:
Access to API blocked by cross-scope privilege
What does this mean?
Q89.
How do you handle cross-scope access properly?
25. Debugging
Q90. ⭐⭐⭐
A Business Rule is not executing.
What would you check?
A good troubleshooting sequence:
1. Table
2. Active
3. When
4. Insert/Update/Delete
5. Condition
6. Advanced condition/script
7. Order
8. Role/security
9. Other Business Rules
10. System logs
Q91.
A Client Script works in Core UI but not in Service Portal.
What would you investigate?
Q92.
A Client Script works in Service Portal but not Workspace.
What could be different?
Q93.
A GlideAjax call returns null.
How would you debug it?
26. Performance
Q94. ⭐
You find this script:
var gr = new GlideRecord('incident');gr.query(); while (gr.next()) { var user = new GlideRecord('sys_user'); user.get(gr.caller_id); }
There are 100,000 incidents.
What's wrong with this approach?
How would you improve it?
Q95.
Why should you avoid unnecessary GlideRecord queries inside loops?
Q96.
When would you use:
GlideAggregate
instead of GlideRecord?
Q97.
How would you optimize a query that takes several seconds?
27. Security + Scripting Scenario ⭐⭐⭐
Q98.
A user should only see Cases where:
Assigned To = Current User
OR
Current User is a member of Assignment Group
How would you implement this securely?
Would you use:
- Client Script?
- UI Policy?
- ACL?
- Business Rule?
Expected answer: ACL.
Client-side controls should not be relied upon for security.
28. Real Interview Scenario
Q99. ⭐⭐⭐
Your manager gives you this requirement:
"When an Incident is created, check whether the Caller is VIP. If the Caller is VIP, set Priority to 1, assign it to the VIP Support group, send an email to the manager, and create an investigation task."
Explain your complete technical design.
A strong answer would mention:
Before Business Rule
↓
Check Caller/VIP
↓
Set Priority + Assignment Group
↓
After Business Rule / Flow
↓
Create Task
↓
Event / NotificationAnd explain why you wouldn't put everything into one giant Business Rule.
29. Advanced Scenario
Q100. ⭐⭐⭐
A customer says:
"We have 50 Business Rules, 20 Flows and several Client Scripts modifying the same Incident fields. Sometimes the Assignment Group changes unexpectedly."
How would you troubleshoot?
You should discuss:
- Transaction behavior
- Business Rule order
- Before vs After
- Flow execution
- Client Scripts
- Data Policies
- UI Policies
- Audit history
- System logs
- Flow execution details
- Debug Business Rules
- Script Tracer
- Avoiding conflicting automation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @shirishakathula ,
Refer this :
Here you will get some Client script, Business rule & Script include questions for getting hands on !
scenarios of client script,server script .
If my response helped mark as helpful and accept the solution.
