Scenario Based Servcienow Interview Question - Solution
Scenario Based Servcienow Interview Question - Solution
Scenario: The Service Desk team has noticed that many resolved Incident tickets remain in
the "Resolved" state for extended periods. The IT Manager wants to automatically close
Incidents 7 days after they are moved to the "Resolved" state, provided the "Reopen count" is
zero.
Specific Questions:
Detailed Solutions:
1. Solution: A Scheduled Job (System Definition > Scheduled Jobs) is the most
appropriate automation for this scenario. Scheduled Jobs run at defined intervals and
can process multiple records based on specific criteria. This is ideal for a recurring
task like checking and updating Incident records.
2. Solution: The steps would involve:
o Creating a new Scheduled Job.
o Setting the Run field to "Daily" or another appropriate frequency.
o Setting the Run this script option and writing the necessary script.
o In the Condition field, you would likely leave it blank or set it to true to
ensure the script runs every time the job is executed. The filtering logic will be
within the script itself.
3. Solution (Sample Script):
(function() {
var gr = new GlideRecord('incident');
// Query for incidents in the 'Resolved' state
gr.addQuery('state', '=', 6); // Assuming '6' is the value for
'Resolved'
gr.addQuery('reopen_count', '=', 0);
// Query for incidents resolved more than 7 days ago
var sevenDaysAgo = new GlideDateTime();
sevenDaysAgo.addDays(-7);
gr.addQuery('resolved_at', '<=',
sevenDaysAgo.getDisplayValue());
gr.query();
while (gr.next()) {
gr.setValue('state', 7); // Assuming '7' is the value for
'Closed'
gr.update();
gs.log('Incident ' + gr.number + ' automatically closed.');
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
}
})();
Scenario: The Change Management team wants a custom list view that only shows Change
Requests assigned to the logged-in user's assignment group. This view should dynamically
update as the user's assignment group changes.
Specific Questions:
1. How would you create this custom list view with the specified filtering?
2. What ServiceNow feature allows for dynamic filtering based on the logged-in user's
information?
3. Explain how you would ensure this filter applies only to the specific custom list view
and doesn't affect other Change Request views.
Detailed Solutions:
1. Solution: You would create a new List View for the Change Request table
(change_request). When configuring the filter for this view, you would apply the
necessary condition.
2. Solution: You would use a dynamic filter option that leverages system variables
related to the logged-in user. Specifically, you would filter where the "Assignment
group" field "is (dynamic)" and then select "Me (Group)". This dynamic filter
automatically evaluates to the assignment groups of the currently logged-in user.
3. Solution: When creating or modifying the list view, ensure that you are doing so
either by personalizing your own list view (which would only affect you) or by
creating a new named view (e.g., "My Group's Changes"). You can do this by going
to the Change Request list, personalizing the list columns and filters, and then using
the list control menu (gear icon) to save the view with a specific name. To make it
available to others in your group, you might need administrative privileges to create a
new view that is shared with a specific group or role.
Scenario: The IT Manager wants to prevent users from modifying the "Short description"
field on Incident records once they are in the "Closed" state. This is to maintain the integrity
of historical data.
Specific Questions:
1. What type of Business Rule (when) would you use to implement this restriction?
Explain your reasoning.
2. Write a sample script for this Business Rule that checks the Incident's state and
prevents changes to the "Short description" field if the state is "Closed".
3. How would you inform the user that they are not allowed to modify the field?
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
Detailed Solutions:
1. Solution: A "before update" Business Rule on the Incident table (incident) is the
most appropriate. We need to check the state before any updates are committed to the
database.
2. Solution (Sample Script):
if (current.state.changesTo(7) || current.state.getValue() == 7)
{ // Assuming '7' is the value for 'Closed'
if (current.short_description.changes()) {
current.short_description.setValue(previous.short_description); //
Revert to the previous value
gs.addErrorMessage('You are not allowed to modify the
Short description of a closed Incident.');
current.setAbortAction(true); // Prevent the update
}
}
})(current, previous);
Scenario: You have a catalog item for requesting a new mobile device. The business requires
that if the user selects "Yes" for the "Need Data Plan?" variable, a new variable called "Data
Plan Details" should become mandatory.
Specific Questions:
1. What type of client-side script would you use to implement this dynamic mandatory
behavior?
2. Describe the client script type and the event that would trigger this logic.
3. Write a sample client script that achieves this functionality, assuming the "Need Data
Plan?" variable name is need_data_plan (a true/false field) and the "Data Plan
Details" variable name is data_plan_details (a string field).
Detailed Solutions:
1. Solution: An onChange client script is the most suitable for this scenario. We need to
react immediately when the user changes their answer to the "Need Data Plan?"
question.
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
2. Solution:
o Client Script Type: onChange
o Triggering Event: When the value of the need_data_plan variable changes.
o Applied To: The specific catalog item.
o Field Name: need_data_plan
3. Solution (Sample Client Script):
Scenario: You have a catalog item for "Software Installation Request". This request needs to
be approved by the requesting user's manager before the software is provisioned.
Specific Questions:
1. Which ServiceNow feature would you use to implement this approval process for the
catalog item?
2. Describe the key activity you would use in the workflow to handle the manager's
approval.
3. How would you ensure the approval is routed to the correct manager of the person
who submitted the catalog item request?
Detailed Solutions:
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
current.requested_for. Then, you would query the sys_user table to get this
user's record and return the manager field's value (which is the manager's sys_id).
Scenario: When a "New Employee Onboarding" catalog item is submitted and approved,
you need to automatically create two tasks: one for the IT department to create the user's
account and another for HR to handle the onboarding paperwork.
Specific Questions:
1. Within the catalog item workflow, what type of activity would you use to create these
tasks?
2. How would you ensure that these tasks are linked to the specific Request Item
(RITM) generated by the catalog item?
3. Describe how you would set different assignment groups and short descriptions for
each of these tasks within the workflow.
Detailed Solutions:
1. Solution: You would use the "Create Task" workflow activity twice, once for each
task you need to create.
2. Solution: When a catalog item is submitted, a Requested Item (RITM) record is
automatically created. The "Create Task" activity, by default, creates tasks that are
linked to this RITM through the request_item field on the task record (sc_task).
The workflow context inherently maintains this relationship.
3. Solution: Within each "Create Task" activity, you would configure the following
properties:
o Task Table: Set this to sc_task (Service Catalog Task).
o Short Description: Provide a specific description for each task (e.g., "Create
New User Account", "Process Onboarding Paperwork").
o Assignment Group: Select the appropriate group for each task (e.g., "IT -
User Administration", "Human Resources").
o You can also set other relevant fields like Priority, Description, Due Date, etc.,
within each "Create Task" activity as needed.
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
Scenario: Your company wants to display relevant knowledge articles from an external
knowledge base within ServiceNow Incident forms. The external knowledge base has a
REST API that allows you to search articles based on keywords.
Specific Questions:
1. What ServiceNow feature would you use to interact with this external REST API?
2. Describe the steps involved in setting up this integration in ServiceNow to query the
external knowledge base.
3. Assuming the external API endpoint for searching articles is
https://api.external-kb.com/articles?query=<keyword> and it returns a
JSON response containing an array of article titles and links, how would you
construct the REST message and process the response in ServiceNow to display the
titles?
Detailed Solutions:
1. Solution: REST Message (under System Web Services > Outbound) is the primary
ServiceNow feature for making outbound REST API calls.
2. Solution: The steps involved would be:
o Create a REST Message: Navigate to System Web Services > Outbound >
REST Message and create a new record. Provide a name (e.g., "External KB
Integration") and the base URL (https://api.external-kb.com).
o Create a REST API Method: Within the REST Message, create a new HTTP
Method.
▪ Set the HTTP Method to "GET".
▪ Set the Endpoint to /articles.
▪ Define a Variable (e.g., keyword) in the HTTP Method's "Variables"
section to dynamically insert the search term. The endpoint would then
look like /articles?query=${keyword}.
▪ Configure any necessary HTTP Headers (e.g., Authorization if
required).
o Write a Script to Trigger the API Call and Process the Response: You
would likely use a Business Rule (e.g., when an Incident is opened or
updated) or a Client Script (to trigger on demand) to make the API call. This
script would:
▪ Create an instance of the REST Message API (using new
sn_ws.RESTMessageV2()).
▪ Set the HTTP method and endpoint (using the variable).
▪ Set the value for the keyword variable based on the Incident's short
description or other relevant fields.
▪ Send the request and handle the JSON response.
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
if (httpStatus == 200) {
try {
var parsedResponse = JSON.parse(responseBody);
var articles = parsedResponse.articles; // Assuming the
JSON has an 'articles' array
})(current, previous);
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
Specific Questions:
1. What are the first steps you would take in ServiceNow to begin troubleshooting why
the approval is not progressing?
2. What specific information would you look for in the Workflow Context and the
"Approval - Group" activity's details?
3. What are some common reasons why an "Approval - Group" activity might get stuck,
and how would you identify which one is the cause?
Detailed Solutions:
In the "Approval - Group" activity's details (in the Workflow Editor), you would
examine:
3. Solution: Common reasons why an "Approval - Group" activity might get stuck and
how to identify them:
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
Scenario: You have a "before insert" Business Rule on the Incident table that retrieves
information from three different related tables based on the caller and sets some custom fields
on the new Incident record. Users report that creating new Incidents is slow.
Specific Questions:
1. What are some potential performance bottlenecks in this type of Business Rule?
2. Describe at least two strategies you could use to optimize the performance of this
Business Rule.
3. Provide a conceptual example of how you might reduce the number of GlideRecord
queries in this scenario.
Detailed Solutions:
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
Scenario: You need to write a script to find all active Problem records that were created in
the last 30 days and are assigned to the "Problem Management" group.
Specific Questions:
1. Write a GlideRecord query that retrieves these Problem records. Specify the table and
the conditions you would use.
2. Explain the purpose of the addQuery() and addEncodedQuery() methods in
GlideRecord. When might you use each?
3. How would you iterate through the results of this GlideRecord query and access the
"Number" and "Short description" fields of each Problem record?
Detailed Solutions:
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq
©️SHAAH ABIIR
while (problemRecords.next()) {
// Process each Problem record
gs.log('Problem Number: ' + problemRecords.number + ', Short
Description: ' + problemRecords.short_description);
}
2. Solution:
o addQuery(field, operator, value): This method adds a simple condition
to the GlideRecord query. You specify the field name, the operator (e.g., '=',
'!=', '>', '<', 'IN', 'LIKE'), and the value to compare against. It's useful for
building queries step-by-step with individual conditions.
o addEncodedQuery(encodedQuery): This method allows you to add a
complex query string that is already formatted in the ServiceNow encoded
query syntax. You might get this encoded query from filtering a list view and
then right-clicking in the filter breadcrumbs to "Copy query". This is useful
for applying multiple complex conditions at once or reusing existing filter
logic.
3. Solution: You would use a while (problemRecords.next()) loop to iterate
through each Problem record that matches the query. Inside the loop,
problemRecords represents the current Problem record. You can access the fields
using dot notation (e.g., problemRecords.number to get the "Number" field and
problemRecords.short_description to get the "Short description" field).
©️This Content Is Solely Prepared by SHAAH ABIIR, If You Want to Meet Me One-On-One, Please Book
an Appointment with Me Here: https://tinyurl.com/2brstwjq