Skip to content
ServiceNow Interview Q&A 17 min read 13 sections

ServiceNow Scenario Based Interview Questions and Answers

The scenario round comes after the definition round. The panel stops asking what a Business Rule is and hands you a requirement instead. Ten scenarios are worked through below with the questions asked against each one, and real script where the scenario asks for script. Four shorter access and assig

RL

RizeX Labs

RizeX Labs

Published

Last updated

Related programme

ServiceNow Training

ITSM, CMDB, scripting and Flow Designer taught on a live instance, with a build project and interview practice before profiles reach the hiring partners.

See the curriculum

3000+ learners · 270+ hiring partners

The scenario round comes after the definition round. The panel stops asking what a Business Rule is and hands you a requirement instead. Ten scenarios are worked through below with the questions asked against each one, and real script where the scenario asks for script. Four shorter access and assignment questions follow. The level is admin and developer, fresher to about three years.

Scenario 1: Resolved Incidents should automatically close after 7 days if the reopen count is zero

What type of ServiceNow automation would be best suited to handle this requirement? Explain your reasoning.

A Scheduled Job, as a Scheduled Script Execution or a scheduled Flow. The requirement is time based, not event based: nothing happens to the incident on day seven, so a Business Rule has no insert or update to hook into. The platform also ships an Autoclose Incidents job driven by a system property holding the day count, so mention that before customising.

Describe the steps you would take to configure this automation, including any conditions you would need to set.

  1. Create a Scheduled Script Execution, run Daily, at a quiet hour.
  2. Query incident on state Resolved, reopen_count 0, and resolved_at seven or more days old.
  3. Set state Closed and fill close code and close notes, which are usually mandatory.
  4. Call setWorkflow(false) if you do not want thousands of closure notifications.
  5. Test in a sub production instance with a shorter day count, then ship it in an update set.

Write a sample script that checks the Resolved date and Reopen count to determine if an Incident should be automatically closed.

(function autoCloseResolvedIncidents() {

    var inc = new GlideRecord('incident');
    inc.addQuery('state', 6);              // Resolved
    inc.addQuery('reopen_count', 0);
    inc.addQuery('resolved_at', '<=', gs.daysAgoStart(7));
    inc.query();

    while (inc.next()) {
        inc.setValue('state', 7);          // Closed
        inc.setValue('close_code', 'Solved (Permanently)');
        inc.setValue('close_notes', 'Closed automatically after 7 days with no reopen.');
        inc.update();
    }
})();

gs.daysAgoStart(7) gives the start of the day seven days back. Confirm the close code choice value on the instance, because that list is often customised.

Scenario 2: A custom list view showing only Change Requests assigned to the logged-in user's assignment group

How would you create this custom list view with the specified filtering?

Two objects, because a view and a filter are different things. Create the view under Configure, List Layout with a new view name, then create a module that opens change_request with that view and carries the assignment group condition in its filter. A shared saved filter also works.

What ServiceNow feature allows for dynamic filtering based on the logged-in user's information?

Dynamic filters. On Assignment group, choose the is (dynamic) operator and the option for groups the current user belongs to. These are Dynamic Filter Option records backed by a Script Include, so you can add your own. The encoded query form is assignment_group=javascript:getMyGroups().

How would you ensure this filter applies only to the specific custom list view and doesn't affect other Change Request views?

Keep the condition in the module or saved filter, never in a before query Business Rule or a default table filter. A query Business Rule rewrites every query on change_request for that user, so reports, related lists and the change manager's own list all start losing records.

Scenario 3: Prevent users from modifying the Short Description of an Incident once it reaches the Closed state

What type of Business Rule would you use to implement this restriction? Explain your reasoning.

A before update Business Rule on incident, conditioned on state Closed. Before means it runs after submit and ahead of the write, so you can restore the value or abort. A read only UI Policy protects only the browser: list edit, import sets, REST and background scripts all walk past it. The server side rule covers every path.

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.

(function executeRule(current, previous /*null when async*/) {

    // Rule condition: current.state == 7 && previous.state == 7
    if (!current.short_description.changes())
        return;

    current.setValue('short_description', previous.short_description);
    gs.addErrorMessage('Short Description cannot be changed once the Incident is Closed.');

})(current, previous);

Testing previous.state matters. Without it the rule fires on the update that closes the incident and blocks the agent writing the final description. Use current.setAbortAction(true) to reject the whole save instead of restoring one field.

This question separates candidates who know syntax from candidates who know execution: when the code runs, where it runs, what data it can reach. Client side against server side is the ServiceNow form of that gap.

How would you inform the user that they are not allowed to modify the field?

gs.addErrorMessage() puts a red banner on the form after the save attempt. Add a UI Policy making the field read only when state is Closed so the user sees the restriction before typing. The server message stays as the backstop for list edits and integrations.

Scenario 4: If a user selects "Yes" for "Need Data Plan?", the "Data Plan Details" variable should become mandatory

What type of client-side script would you use to implement this dynamic mandatory behavior?

A Catalog Client Script of type onChange on the item or variable set. Say out loud that a Catalog UI Policy with a UI Policy Action does the same with no code and upgrades better, and that you would script only when the condition is beyond the policy builder.

Describe the client script type and the event that would trigger this logic.

Type onChange, Variable name set to Need Data Plan. It runs on every change of that value and once on load with isLoading true. Tick Applies on a Catalog Item and Applies on Requested Items if the RITM form needs it too. onLoad fires once and misses the change; onSubmit complains only at the end.

Write a sample client script that makes the "Data Plan Details" variable mandatory when "Need Data Plan?" is selected.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue === '') {
        g_form.setMandatory('data_plan_details', false);
        g_form.setDisplay('data_plan_details', false);
        return;
    }

    var needsPlan = (newValue === 'yes'); // choice value on Need Data Plan?

    if (!needsPlan)
        g_form.setMandatory('data_plan_details', false); // clear before hiding

    g_form.setDisplay('data_plan_details', needsPlan);
    g_form.setMandatory('data_plan_details', needsPlan);
}

Use the variable name, not the label. Check the stored value before comparing to 'yes': a checkbox returns 'true', a Yes/No select box usually 'yes', a reference a sys_id. A hidden field left mandatory blocks submission with no visible cause.

Scenario 5: A Software Installation Request must be approved by the requesting user's manager before provisioning

Which ServiceNow feature would you use to implement this approval process for the catalog item?

Flow Designer on a current instance, attached through the Flow field on the catalog item. Legacy Workflow does the same and still runs in plenty of production instances, so know both. The process runs on the Requested Item, because approval and fulfilment belong to the item rather than the parent Request.

Describe the key activity you would use in the workflow to handle the manager's approval.

The Ask for Approval action in Flow Designer, or the Approval - User activity in legacy Workflow. Both create sysapproval_approver records, send the notification and hold execution until the approver responds. Branch the rejected path to set the RITM to Closed Incomplete rather than leaving it open.

How would you ensure the approval is routed to the correct manager of the person who submitted the catalog item request?

Dot walk instead of naming a user. Take Requested for from the RITM, read its Manager field, and fall back to Opened by when Requested for is empty. Check two things before go live: that managers are populated across the user base, since an empty manager creates an approval with no approver, and how self approval is handled when the requester is the manager.

Scenario 6: After a New Employee Onboarding catalog item is submitted and approved, create separate tasks for IT and HR

Within the catalog item workflow, what type of activity would you use to create these tasks?

The Create Task activity in legacy Workflow, or Create Catalog Task in Flow Designer. Use one activity per task, placed in parallel after the approval so IT and HR work at the same time, with a Join activity after the branches.

How would you ensure that these tasks are linked to the specific Request Item (RITM) generated by the catalog item?

The context runs against the sc_req_item record, so the activity stamps the parent Request item on each sc_task. That link puts the task in the Catalog Tasks related list and lets the RITM close when the last task closes. Create the task in script instead and you must set the request item field to current.sys_id yourself, which is the usual reason tasks go missing.

Describe how you would set different assignment groups and short descriptions for each of these tasks within the workflow.

Each Create Task activity carries its own field values. Set the IT activity to the desk group with a description such as "Create AD account and issue laptop", and the HR activity to its own group and text. Catalog variables can be pulled into the description with ${variables.variable_name}, so the joiner's name and start date reach the fulfiller without a lookup.

Scenario 7: Display articles from an external knowledge base inside ServiceNow Incident forms using a REST API

What ServiceNow feature would you use to interact with this external REST API?

An outbound REST Message called from server side script through RESTMessageV2, or an IntegrationHub spoke where one exists. If the knowledge base sits inside the customer network, the call routes through a MID Server.

"Do you know integrations" gets a yes from everyone. "Where have you used it" gets silence. Name the endpoint, the auth type and the record that stored the result.

Describe the steps involved in setting up this integration in ServiceNow to query the external knowledge base.

  1. Get the endpoint, method, auth type and a sample response from the other team.
  2. Create a Credential and Connection alias so no secret sits in script.
  3. Create the REST Message and a GET method with the search text as a parameter, then use Test to confirm a 200 and a readable body.
  4. Wrap the call in a Script Include that returns a trimmed list of titles and links.
  5. Surface it with GlideAjax into a formatter on the form, or a widget on the portal.
  6. Log failures and fall back quietly, because an external outage must not block incident logging.

Assuming the external API returns a JSON response containing article titles and links, how would you construct the REST message and process the response in ServiceNow to display the titles?

searchArticles: function(searchText) {

    var articles = [];

    try {
        var request = new sn_ws.RESTMessageV2('External KB', 'Search Articles');
        request.setStringParameterNoEscape('search_text', searchText);

        var response = request.execute();
        if (response.getStatusCode() != 200) {
            gs.error('External KB search failed: ' + response.getStatusCode());
            return articles;
        }

        var results = JSON.parse(response.getBody()).results || [];
        for (var i = 0; i < results.length; i++) {
            articles.push({ title: results[i].title, url: results[i].link });
        }

    } catch (ex) {
        gs.error('External KB search error: ' + ex.getMessage());
    }

    return articles;
}

The array goes back to the client through GlideAjax and renders as links. Keep JSON.parse inside the try block, because a proxy returning an HTML error page throws there and not at the HTTP call.

Scenario 8: A Change Request workflow is stuck at an "Approval - Group" activity and approvers have not received requests

What are the first steps you would take in ServiceNow to begin troubleshooting why the approval is not progressing?

Start on the record. Open the Change Request and read the Approvers related list. No approval records means the activity never generated them, which is a workflow or group problem. Records sitting in Requested means the approval is fine and the notification is not, so move to the Email Logs. Then open the Workflow context and see which activity is current.

What specific information would you look for in the Workflow Context and the "Approval - Group" activity's details?

From the context: its state, the current activity, the workflow version it is running, and the activity history. A context started on an older published version keeps running that version, which is why this morning's edit changes nothing for yesterday's records.

From the activity: the group it resolved to, whether a group approval record with child approvers exists, and the wait condition, meaning anyone approves, everyone approves, or first response.

What are some common reasons why an "Approval - Group" activity might get stuck, and how would you identify which one is the cause?

Cause How you confirm it
Group empty or members inactive Group members list and the active flag on each user
Everyone approves, one approver inactive Child approver records against current membership
Group resolved by script came back empty Activity input on the context shows no group
Notification never sent Email Logs, plus the user's email and preferences
Older workflow version running Version on the context against the published version
Approvals left at Not Yet Requested State on the sysapproval_approver records

Debugging questions carry more weight than definitions. "Your Business Rule is not firing, what do you check" tells a panel more than "what is a Business Rule", and this one works the same way.

Scenario 9: A before-insert Business Rule runs multiple GlideRecord queries and is slowing down Incident creation

What are some potential performance bottlenecks in this type of Business Rule?

Queries inside a loop, so cost grows with data volume. Queries on unindexed fields, which force a table scan. Large tables queried with no setLimit. Repeated dot walking, where each hop is another read. And the structural one: a before rule is synchronous, so the user's save waits for all of it.

Describe at least two strategies you could use to optimize the performance of this Business Rule.

Collapse several queries into one. Three lookups against the same configuration table can usually be answered by a single ordered query.

Move anything that does not change the record being inserted into an Async Business Rule or a Flow, so it runs after the commit instead of inside the save.

Also useful: setLimit(1) for existence checks, GlideAggregate for counts instead of looping, an index on the filtered field, and reading current rather than re-querying the same record.

Provide a conceptual example of how you might reduce the number of GlideRecord queries in this scenario.

(function executeRule(current, previous /*null when async*/) {

    // Before: separate queries for group, impact and urgency.
    // After: one ordered query against the same routing table.
    var rule = new GlideRecord('u_incident_routing');
    rule.addQuery('active', true);
    rule.addQuery('u_category', current.getValue('category'));
    rule.addQuery('u_subcategory', current.getValue('subcategory'));
    rule.orderBy('u_order');
    rule.setLimit(1);
    rule.query();

    if (!rule.next())
        return;

    current.setValue('assignment_group', rule.getValue('u_assignment_group'));
    current.setValue('impact', rule.getValue('u_impact'));
    current.setValue('urgency', rule.getValue('u_urgency'));

})(current, previous);

Three reads become one, and setLimit(1) stops the database building a result set you never read.

Scenario 10: Find all active Problem records created in the last 30 days and assigned to the "Problem Management" group

Write a GlideRecord query that retrieves these Problem records. Specify the table and the conditions you would use.

var prb = new GlideRecord('problem');
prb.addQuery('active', true);
prb.addQuery('sys_created_on', '>=', gs.daysAgoStart(30));
prb.addQuery('assignment_group.name', 'Problem Management');
prb.query();

The table is problem. The third condition dot walks to the group name, which reads well but joins to sys_user_group on every run. For a query that runs often, resolve the group sys_id once and filter on that.

Explain the purpose of addQuery() and addEncodedQuery() methods in GlideRecord. When might you use each?

addQuery() adds one condition as field, operator and value, and conditions join with AND. Use it for conditions written in script, especially when a value comes from a variable.

addEncodedQuery() takes a single encoded string, the one the list filter produces under Copy query. Use it for complex filters, filters with OR groups, or a filter stored in a system property so an admin can change it without a code release. The trade off is that a typo returns the wrong rows silently instead of raising an error. Both can be used on the same object.

How would you iterate through the results of this GlideRecord query and access the Number and Short Description fields of each Problem record?

while (prb.next()) {
    gs.info(prb.getValue('number') + ' : ' + prb.getValue('short_description'));
}

next() moves the cursor and returns false when the rows run out. Prefer getValue() over prb.number, which returns a GlideElement object and behaves unexpectedly in comparisons. On a reference field, getDisplayValue() gives the label and getValue() the sys_id.

Four more scenario questions on access and assignment

Explain access control behavior with multiple roles.

An ACL passes only when its condition, its script and its role list all pass. Within one ACL the roles are an OR, so any single listed role is enough. A field read is checked against the field level rule and the table level rule, with the more specific rule evaluated before the wildcard. A user holding three roles who still cannot see the record is usually failing a condition or a script, not the role check.

How do you show inactive incidents only to admins?

A before query Business Rule on incident that adds an active condition when the current user does not hold the admin role. Running at query time covers lists, related lists, reports and search in one place. That is the same behaviour that made a query Business Rule the wrong answer in Scenario 2 and the right answer here.

What are assignment rules?

Configuration records that set Assignment group and Assigned to on a task from a set of conditions, with no script. Each rule carries a table, a condition, the values to apply and an order number. They are the no code option to try before a Business Rule or a Flow.

How do assignment rules work with category and subcategory?

Build the condition on both fields, for example category Network with subcategory VPN, and set the owning group. The order number decides which rule wins when more than one matches, so a broad category only rule and a narrow category plus subcategory rule need their order planned and then tested on a real record rather than assumed. Also confirm whether the rule should apply on update as well as insert.

What the interviewer is actually checking

  • Whether you match the tool to the timing. Scheduled Job for time based, Business Rule for event based, client script for the form.
  • Whether you know where your code runs. Client side against server side, before against after, synchronous against async. Knowing syntax is not knowing when it executes or what data it can reach.
  • Whether you can debug. The stuck approval question is worth more than any definition, because it shows how you narrow a problem down instead of guessing.
  • Whether your examples are specific. A named table, a named field, and the reason you chose this option over the other one.
  • Whether you think about blast radius. A query Business Rule that hides records everywhere, a job that sends four thousand emails, a hidden mandatory field that blocks submission.

Practise these before the interview

Build three of these scenarios on a Personal Developer Instance and break them deliberately. Close an incident with the field restriction active and read the error. Empty the approval group and watch the workflow sit. That is the difference between an answer that sounds correct and an answer with a story behind it, told as situation, approach, reason and result.

RizeX Labs runs ServiceNow training in Pune built around this kind of scenario work, with instance access and mock interview rounds on the same material.