Top 60 ServiceNow Interview Questions and Answers [2024]

This article is mostly about the ServiceNow interview questions based on different coding interview questions which will help you to prepare and execute perfectly in the interview. As we all know ServiceNow professionals are growing every day and there is a huge demand for the tool overall there are also some professionals who want to switch from the remedy or HP QC or IBM Maximo to ServiceNow.

There are various job profiles in the ServiceNow tool which are Administrator, Developer, Architect, Business Analyst, CMDB manager, etc and not everyone gets the chance to work on their profile, thus some professionals want to switch job and move from Developer to Architect profile.

Giving an Interview and working in the company is a different perspective as every company has its own business needs and thus below ServiceNow interview questions will not only help to crack the interview but also will help to know some basic scripting.

Table of Contents

ServiceNow Interview Questions and Answers on Client Script

What is the Client Script?

It is the script that let you run JavaScript on the web browser side (client) for example when the form/page is loading or when any operation is required on field change.

What are the types of client scripts?

There are four types of client scripts.

  1. OnLoad()
  2. OnChange()
  3. OnSubmit()
  4. onCellEdit()

How to make the field mandatory in the client script?

In the client script, you need to write syntax g_form.setMandatory(‘field name’, true);

How to make the field read-only through client script?

We  can write syntax g_form.setReadOnly(field name, true);

How you can hide a field from the form?

We can write syntax in the client script   g_form.setVisible('field name',false);

How to get the logged-in user in the client script?

It can be done by g_user.userID.

How to change the background color of the field in the list view?

It can be done through right-click the on-field label and selecting configure styles and click on new.

servicenow background color- servicenow coding interview questions

servicenow field style - servicenow coding interview questions

column - servicenow coding interview questions

We can do like

field style priority - servicenow coding interview questions

You can also write a script inside the value like

javascript: current.priority == '2' for any other field value

Then you will see

servicenow list - servicenow coding interview questions

How to call service side script in client script?

Yes it can be called like

var ga = new GlideAjax('HelloUniverse');

ga.addParam('sysparm_name', 'helloUniverse');

ga.addParam('sysparm_user_name', "Builder");

ga.getXML(HelloUniverseParse);

function HelloUniverseParse (response) {

var answer = response.responseXML. documentElement.getAttribute("answer");

alert(answer); }

What is the use of isLoading in client script?

It provides the Boolean value true if the change on the respective field is done has happened due to form load or any other onload script have run.

What is the use of isTemplate in client script?

It also provides Boolean value true if the change on the field is happened due to template.

How to get the value of a field in client script?

You can write script var fieldxyz = g_form.getValue(field);

Can we write GlideRecord in client script?

Yes, we can write GlideRecord in client script but as per good practise it should not be used and instead, we should do a similar operation from GlideAjax or we can use getReference with a callback function.

How to use info message in client script ServiceNow?

It can be done through g_form.addErrorMessage(); and if we want to add error message then we can use g_form.addErrorMessage();.

Give ServiceNow client script examples.

Scenario 1: There is a requirement to check if the caller title is the architect

How we can do it by using get Reference and call back function.

Field: caller_id

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

var caller = g_form.getReference('caller_id', doInfo); // doInfo is our callback function

}

function doInfo(caller) { //reference is passed into callback as first arguments

if (caller.title == 'Architect')

alert('Caller is a VIP!');

}

Scenario2: There is a need to check the phone number format of the user

You can write an on change client script

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

if (isLoading || newValue === '') {

return;

}

var contact = g_form.getValue('u_contact_number');

var pattern = /^[(]?(\d{3})[)]?[-|\s]?(\d{3})[-|\s]?(\d{4})$/;

if (!pattern.test(contact)) {

alert('Please enter a valid contact number');

g_form.setValue('u_contact_number', '');

}

}

For more regex https://docs.servicenow.com/bundle/sandiego-application-development/page/script/general-scripting/concept/c_RegularExpressionsInScripts.html

Give some supported client-side APIs?

Below is the list of client-side API, you can select any

  1. addDecoration(fieldName, icon, title)
  2. addErrorMessage(message)
  3. addInfoMessage(message)
  4. addOption(fieldName, value, label, index)
  5. clearOptions(fieldName)
  6. getActionName()
  7. getBooleanValue(fieldName)
  8. getDecimalValue(fieldName)
  9. getEncodedRecord()
  10. getFieldNames()
  11. getIntValue(fieldName)
  12. getLabel(fieldName)
  13. getReference(fieldName, callback)
  14. getRelatedListNames()
  15. getSectionNames()
  16. getSysId()
  17. getTableName()
  18. getValue(fieldName)
  19. hasField(fieldName)
  20. hideAllFieldMsgs(type: “info | error”)
  21. hideErrorBox(fieldName)
  22. hideFieldMsg(fieldName, clearAll)
  23. hideRelatedList(listTableName)
  24. hideRelatedLists()
  25. isMandatory(fieldName)
  26. isNewRecord()
  27. isReadOnly(fieldName)
  28. isVisible(fieldName)
  29. removeDecoration(fieldName, icon, title)
  30. removeOption(fieldName, value)
  31. save()
  32. serialize(onlyDirtyFields)
  33. setFieldPlaceholder(fieldName, placeholder)
  34. setLabel(fieldName, label)
  35. setMandatory(fieldName, isMandatory)
  36. setReadOnly(fieldName, isReadOnly)
  37. setSectionDisplay(sectionName, isVisible)
  38. setValue(fieldName, value, displayValue)
  39. setVisible(fieldName, isVisible)
  40. showErrorBox(fieldName, message, scrollForm)
  41. showFieldMsg(fieldName, message, type: “info | error”, scrollForm)
  42. showRelatedList(relatedTableName)
  43. showRelatedLists()
  44. submit(submitActionName)

Check More on ServiceNow API

ServiceNow Basic Interview Questions

What is ServiceNow’s latest version?

San Diego

Name ServiceNow Versions?

Check the list of all ServiceNow Versions and history

Name the latest user interface version?

Next Experience UI

ServiceNow Next Experience UI

Is there any ServiceNow Mobile application?

Yes, ServiceNow has both Android and IOS applications.

How does ServiceNow support their versions?

ServiceNow supports the current and one prior version and gives a deadline to the customer to upgrade their environments.

ServiceNow Interview Questions and Answer on Business Rule

What is a business rule?

It is the server-side script that runs when any record is inserted, updated, deleted, or displayed.

How to insert a new record in another table through business rule?

You can write an on after business rule depending on your need and just need to write the below code to insert values in another table.

var grNew = new GlideRecord(‘tablename’);

grNew.initialize();

grNew.name = current.name;

grNew.field1= current.field1;

grNew.field2= current.field2;

grNew.field3= current.field3;

grNew.insert();

Here the current is referred to the table from which the business rule is written on.

How to make attachment mandatory through Business Rule?

To make attachment mandatory when you need to write a before business rule so that before save or submit error will be appear

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

{

if (current.hasAttachments() == true)

{

//do nothing

gs.addInfoMessage('Add some info message if you want to’);

}

else

{

gs.addErrorMessage(‘Attachment is mandatory, Please add attachment’);

current.setAbortAction(true);

}

})(current, previous);

What is the get method and how to use it in the business rule?

You got a requirement that there is some generic CI from you need to pick assignment group and default assigned to when an incident is created. Thus to get all the details of the CI record we can use get.

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

// Create a GlideRecord object

var grCI = new GlideRecord(‘cmdb_ci’);

grCI.get('PASTE_USER_SYS_ID_HERE');

// add the assignment group and assigned to the incident form.

current.assignment_group = grCI.assignment_group;

current.assigned_to = grCI.u_default_assigned;

})(current, previous);

How to update records without updating system fields?

Before the updating business rule you need to write autoSysFields(false); and setWorkflow(false); for example, you need to update all user language to English.

var gr = new GlideRecord('sys_user');

gr.query();

while (gr.next()) {

gr.language = ‘en’;

gr.setWorkflow(false); //Do not run business rules

gr.autoSysFields(false); //Do not update system fields

gr.update();

}

What is Glide Aggregate?

The GlideAggregate is an extension of GlideRecord which helps to do the calculations faster. It can be used for reports or condition where there is a need for calculations. We can use COUNT, SUM, MIN, MAX, AVG in GlideAggregate.

How to trigger a notification from the business rule?

We need to fire an event and which be done by gs.eventQueue(‘knowledge.approval,current, current.number,gs.getUserName()); and the notification condition when to run should be “when event is triggered” specify the event name.

How to remove extra spaces from a text in ServiceNow?

We can use function trim or we can use regex

Var str = ‘abcdddd     ’;

Str = str.trim()

Or we can use  str= str.replace(/^\s+|\s+$/g, "");

How to use scratchpad in the business rule?

We can use g_scratchpad.public = current.u_public; this way the variable public can be accessed in client script also.

example

if(g_scratchpad.public == “true”)

{

g_form.setValue(‘u_public’,’it is public’)

}

What is the difference between after and async business rule in ServiceNow?

Before query business rules example?

ServiceNow Interview Questions and Answer on Script Include

What is the script include?

It is server-side script or it stores the JavaScript which runs on the server. It is used in client script or it can be called from any field.

Basic syntax

var MyScriptInclude = Class.create();

MyScriptInclude.prototype = {

initialize: function() {

},

type: 'MyScriptInclude'

};

How to make client callable script include?

There is a checkbox on the script include form if checked it makes any script include client callable thus can be used in client scripts

var MyScriptInclude = Class.create();

MyScriptInclude.prototype =

Object.extendsObject

(AbstractAjaxProcessor, {

type: 'MyScriptInclude'

});

ServiceNow Interview Questions and Answer on Transform Maps

What is a Transform map? What is the use of the Transform map?

Transform map is a set of fields that are mapped between import set fields and the target tables fields. It is used for data loading and integration, the most common use is to load user data in sys_user table or to create an incident from any integration where the transform is required in data before inserting in the incident table.

Can we use scripting in the transform map?

Yes, we can use scripting in transform map just you need to click on run script.

transform scripts - servicenow coding interview questions

How many types of transform scripts are there?

There are 7 types of transform scripts as shown below in the image.

transform scripts - servicenow coding interview questions

ServiceNow Interview Questions and Answer on Record Producer

What is the Record Producer?

Its is a catalog item which helps to create any task-based records from the service portal/ UI. It is used in all the projects to create incidents when end users do not have application access.

How we can use scripts in record producer?

If there is a new to write any script, we either need to set value in target record ex – an incident or we need to get variable value and do some operation.

Used for the target record: current.*FIELD_NAME*

Used for accessing or get value of record producer variable:  producer.*VARIABLE_NAME*

How to redirect after submission of record producer?

We can redirect by following code written in producer script

UI: producer.redirect="home.do";

Service Portal: producer.portal_redirect = "sp?id=sc_home"

ServiceNow Interview Questions and Answer on Workflow

What is the workflow? How we use workflow?

Workflow is a flow chart of activities that need to be performed to complete the operation. Workflow editor is the graphical interface where you can combine the pre-defined activities by just drag and drop and then publish as workflow.

transform workflow - servicenow coding interview questions

It is considered a legacy product but not obsolete.

How to cancel the workflow?

There are two ways to do it either go to workflow> active contexts and filter your record and applied workflow and cancel it through the context menu. Another way if you want to do it dynamically by adding the below code

new Workflow().cancel(current);
new WorkflowApprovalUtils(). cancelAll(current, comment);

How to restart the workflow?

new Workflow().restartWorkflow(current); or new Workflow().restartWorkflow(gr); where gr is sys_id of the record.

What are condition workflow activities?

These are the activities which get executed only once the criteria are fulfilled.

  1. If workflow activity
  2. Switch workflow activity
  3. Wait for condition workflow activity
  4. The Wait for Workflow WF Event

How to use scratchpad in a workflow?

Scratchpad is a special variable which can be sued in whole workflow execution and can be declared as workflow.scratchpad.count =10;

ServiceNow Interview Questions and Answer on Scripts

What is the fix script? How to use them?

It is a server-side script and the main purpose of it to run after any application installation or upgrade. Thus, this maintains the stability of the application by modifying some settings. Users who have admin access can run this script.

What is the background script? How to use them?

The background script is a terminal provided by ServiceNow where you can write any script to execute. It is very helpful for debugging the code but at the same time, it needs to be used very carefully as we don’t have to provide any condition to run it its just script and click on run.

How to find slow scripts?

You need to go in application navigator and type system diagnostics and then under stats, you can find slow scripts, this is kind of report which measure who long any scripts are running and thus this way you can identify the performance issue and correct the scripts.

What is Email Notification Scripts? How to use them?

Notification scripts are server-side script which is embedded to emails to provide the dynamic values in the email. For example, you need to provide some dynamic hyperlinks of related records to an incident etc.

How to add email notification scripts in a notification.

You can embed by adding ${mail_script:script name} in the email.

What are cleanup scripts? How to use them?

Clean scripts are the server-side script and responsible to handle the post clone execution which is needed to repair the data or clean up the data. For example, when doing cloning from prod to no prod there is some table which contains confidential information which needs to be removed in non-prod environment thus with the cleanup scripts we can either delete it or just remove the column containing it.

ServiceNow Interview Questions and Answer on UI Actions

What are UI Actions? Types of UI Actions?

Ui Actions are button, links, context menu on the form and the list. So it is a clickable button which helps to perform some operations in ServiceNow.

Types

  • A button on a form.
  • A context menu item on a form that appears when you open the form context menu or right-click the form header.
  • A related link in a form.
  • A button in the banner on top of a list.
  • A button at the bottom of a list.
  • A context menu item on a list that appears when you open the list context menu or right-click the list header.
  • A menu item for the action choice list at the bottom of a list.
  • A related link at the bottom of a list.

Source

How to display UI Action on form Dynamically?

we can define conditions in UI action itself and based on the condition it will be visible.

How to hide UI Actions for few tables only?

You need to add condition like current.getTableName() != '< table name>'

ServiceNow Interview Questions and Answer on UI Macro

What is UI Macro?

UI Macro is scripted component which canned be added on form or on UI interface.

You can create them y typing UI macro in application navigator

System UI > UI Macros >New

UI Macro

How to add UI Macro on the form field?

Lets take an example to call Microsoft Teams on Caller Field.

UI Macro

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);"/>

<j:set var="jvar_n" value=" show_incidents_${jvar_guid}:${ref}"/>
<div id="popup_teams">
<a class="btn-default;" id="${jvar_n}" onclick="invokeChat('${ref}');">

<img src="teams.png" width="30" title="Popup Teams" alt="${gs.getMessage('Click to open Teams chat')}" />

</a>
</div>
<script>

function invokeChat(reference) {

var s = reference.split('.');

var tableName = s[0];

var referenceField = s[1];

var v = g_form.getValue(referenceField);

var email;

var gr = new GlideRecord('sys_user');

if (gr.get(v)) {

email = gr.email;

}

var url = 'https://teams.microsoft.com/l/chat/0/0?users='+email;

var w = getTopWindow();

w.open(url);

}

</script>

</j:jelly>

Write this in Caller_id field attribute

ref_ac_columns_search=true, ref_contributions=popup_teams, ref_ac_columns=user_name;email, ref_auto_completer=AJAXTableCompleter, edge_encryption_enabled=true

ServiceNow Microsoft teams

ServiceNow Interview Questions and Answer on UI Script

What is UI Script?

How to call UI Script in Client script?

How to get a user object in UI Script?

What is UI Type in UI Script?

How to use UI script in the UI page?

Share some best practices while using UI scripts?

ServiceNow Interview Questions and Answer on Domain Separation

What is domain separation?

What are contains means in domain separation?

Is system properties is domain separated table?

Do global domain scripts run on other domains also?

How to make a table domain separated?

Please let us know in the comment section if you have some ServiceNow interview questions which may help our colleagues to pass the interview or share your experience.

Other ServiceNow interview questions resources which may help you to clear the interview

ServiceNow Resume Samples Download

ServiceNow Admin Interview Questions

ServiceNow Developer Interview Questions

ServiceNow CMDB Interview Questions

Learn ServiceNow

5 thoughts on “Top 60 ServiceNow Interview Questions and Answers [2024]”

  1. All the Topics were covered and provided main important information, This helps to clear the Interview for 0 -3 years’ experience candidate.

    Reply
  2. Wow, thank you so much for sharing this comprehensive list of ServiceNow interview questions! As a current ServiceNow consultant, I can attest to the accuracy of these questions and how helpful they are in preparing for interviews. Your blog post has definitely saved me a lot of time and effort in my job search. Keep up the great work! 👍😊

    Reply

Leave a Comment

error: Content is protected !!