0% found this document useful (0 votes)
178 views

ServiceNow Interview

The document provides sample scripts for automating common processes in ServiceNow like incident creation, service catalog item creation, change request approval, and more. For each process, it includes a brief description and a JavaScript script example to programmatically perform the automation, such as automatically approving change requests that meet certain criteria. There are scripts provided for 14 different ServiceNow features.

Uploaded by

MD MUSTAKIM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views

ServiceNow Interview

The document provides sample scripts for automating common processes in ServiceNow like incident creation, service catalog item creation, change request approval, and more. For each process, it includes a brief description and a JavaScript script example to programmatically perform the automation, such as automatically approving change requests that meet certain criteria. There are scripts provided for 14 different ServiceNow features.

Uploaded by

MD MUSTAKIM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Certainly!

Here are 30 real-time scenario interview


questions along with sample answers and scripts for
ServiceNow:

1. Incident Management:
Question: How would you automate the creation of
incidents in ServiceNow?
Answer: We can automate the creation of incidents in
ServiceNow by configuring event rules and workflows.
Here's a sample script that creates an incident when a
specific event occurs:

```javascript
// Sample script to create an incident from an event
(function() {
var event = current; // Assuming the event data is available
in the 'current' object

var incident = new GlideRecord('incident');


incident.initialize();

// Set incident field values based on the event data


incident.short_description = 'Event: ' + event.name;
incident.description = 'Event details: ' + event.details;
incident.category = 'Hardware'; // Set the appropriate
category
incident.subcategory = 'Network'; // Set the appropriate
subcategory
incident.impact = 2; // Set the appropriate impact level
incident.urgency = 2; // Set the appropriate urgency level

incident.insert();
})();
```

2. Service Catalog:
Question: How would you create a new service catalog item
in ServiceNow?
Answer: We can create a new service catalog item in
ServiceNow by defining the item details, variables, and
workflows. Here's a sample script that creates a new service
catalog item:

```javascript
// Sample script to create a new service catalog item
(function() {
var catalogItem = new GlideRecord('sc_cat_item');
catalogItem.initialize();

// Set catalog item field values


catalogItem.name = 'New Item';
catalogItem.short_description = 'Description of the new
item';
catalogItem.category = 'Hardware'; // Set the appropriate
category
catalogItem.price = 100.00; // Set the appropriate price

catalogItem.insert();
})();
```

3. Change Management:
Question: How would you automate the approval process
for change requests in ServiceNow?
Answer: We can automate the approval process for change
requests in ServiceNow by configuring approval rules and
workflows. Here's a sample script that automatically
approves change requests:

```javascript
// Sample script to automatically approve change requests
(function() {
var changeRequest = current; // Assuming the change
request data is available in the 'current' object

if (changeRequest.state == 1) { // Check if the change


request is in the 'Requested' state
changeRequest.approval = 'approved';
changeRequest.update();

gs.addInfoMessage('Change request ' +


changeRequest.number + ' has been automatically
approved.');
}
})();
```

4. Configuration Management Database (CMDB):


Question: How would you create a new CI (Configuration
Item) in the CMDB in ServiceNow?
Answer: We can create a new CI in the CMDB in ServiceNow
by defining the CI details and relationships. Here's a sample
script that creates a new CI:
```javascript
// Sample script to create a new CI in the CMDB
(function() {
var ci = new GlideRecord('cmdb_ci');
ci.initialize();

// Set CI field values


ci.name = 'New CI';
ci.description = 'Description of the new CI';
ci.ci_class = 'Hardware'; // Set the appropriate CI class

ci.insert();
})();
```

5. Knowledge Management:
Question: How would you automate the publishing of
knowledge articles in ServiceNow?
Answer: We can automate the publishing of knowledge
articles in ServiceNow by configuring approval rules and
workflows. Here's a sample script that automatically
publishes knowledge articles:
```javascript
// Sample script to automatically publish knowledge articles
(function() {
var knowledgeArticle = current

; // Assuming the knowledge article data is available in the


'current' object

if (knowledgeArticle.state == 1) { // Check if the knowledge


article is in the 'Draft' state
knowledgeArticle.state = 2; // Set the state to 'Published'
knowledgeArticle.update();

gs.addInfoMessage('Knowledge article ' +


knowledgeArticle.number + ' has been automatically
published.');
}
})();
```

6. Service Level Management:


Question: How would you automate the calculation of SLA
targets in ServiceNow?
Answer: We can automate the calculation of SLA targets in
ServiceNow by configuring SLA definitions and schedules.
Here's a sample script that calculates the SLA target based
on the priority:

```javascript
// Sample script to calculate the SLA target based on priority
(function() {
var sla = new GlideRecord('contract_sla');
sla.initialize();

// Set SLA field values


sla.name = 'New SLA';
sla.description = 'Description of the new SLA';
sla.priority = '1'; // Set the appropriate priority

// Calculate the SLA target based on the priority


if (sla.priority == '1') {
sla.resolution_time = '4 hours';
} else if (sla.priority == '2') {
sla.resolution_time = '8 hours';
} else {
sla.resolution_time = '24 hours';
}

sla.insert();
})();
```

7. Problem Management:
Question: How would you automate the closure of problem
records in ServiceNow?
Answer: We can automate the closure of problem records in
ServiceNow by configuring problem closure rules and
workflows. Here's a sample script that automatically closes
problem records:

```javascript
// Sample script to automatically close problem records
(function() {
var problem = current; // Assuming the problem record
data is available in the 'current' object

if (problem.state == 2) { // Check if the problem record is in


the 'Resolved' state
problem.state = 6; // Set the state to 'Closed'
problem.update();

gs.addInfoMessage('Problem record ' + problem.number +


' has been automatically closed.');
}
})();
```

8. Asset Management:
Question: How would you automate the retirement of
assets in ServiceNow?
Answer: We can automate the retirement of assets in
ServiceNow by configuring asset retirement rules and
workflows. Here's a sample script that automatically retires
assets:

```javascript
// Sample script to automatically retire assets
(function() {
var asset = current; // Assuming the asset data is available
in the 'current' object

asset.install_status = 7; // Set the install status to 'Retired'


asset.update();

gs.addInfoMessage('Asset ' + asset.name + ' has been


automatically retired.');
})();
```

9. Service Portal:
Question: How would you customize the Service Portal
using widgets in ServiceNow?
Answer: We can customize the Service Portal in ServiceNow
by configuring and creating custom widgets. Here's a sample
script that creates a custom widget:

```javascript
// Sample script to create a custom widget for the Service
Portal
(function() {
angular.module('widget.module',
[]).directive('customWidget', function() {
return {
template: '<div>This is a custom widget.</div>',
restrict: 'E'
};
});
})();
```

10. Service Mapping:


Question: How would you automate the discovery of
services in ServiceNow using Service Mapping?
Answer: We can automate the discovery of services in
ServiceNow using Service Mapping by configuring discovery
probes and patterns. Here's a sample script that triggers the
service mapping process:

```javascript
// Sample script to trigger service mapping discovery
(function()

{
var discovery = new GlideDiscovery();

// Set the appropriate discovery options


var options = {
ip_range: '192.168.0.0/24',
credentials: 'admin:password'
};

// Start the service mapping discovery


discovery.triggerProbe(options);
})();
```

11. HR Service Delivery:


Question: How would you automate the onboarding process
for new employees in ServiceNow?
Answer: We can automate the onboarding process for new
employees in ServiceNow by configuring HR workflows and
tasks. Here's a sample script that triggers the onboarding
process:

```javascript
// Sample script to trigger the onboarding process for a new
employee
(function() {
var employee = new GlideRecord('hr_employee');
employee.initialize();
// Set employee field values
employee.name = 'John Doe';
employee.department = 'IT'; // Set the appropriate
department

employee.insert();

gs.addInfoMessage('Onboarding process triggered for


employee: ' + employee.name);
})();
```

12. Software Asset Management:


Question: How would you automate the software license
compliance checks in ServiceNow?
Answer: We can automate the software license compliance
checks in ServiceNow by configuring software asset
management rules and workflows. Here's a sample script
that checks license compliance:

```javascript
// Sample script to check software license compliance
(function() {
var softwareAsset = current; // Assuming the software
asset data is available in the 'current' object

if (softwareAsset.installed > softwareAsset.licensed) {


gs.addErrorMessage('Software asset ' +
softwareAsset.name + ' is not compliant. Licenses
exceeded.');
} else {
gs.addInfoMessage('Software asset ' +
softwareAsset.name + ' is compliant.');
}
})();
```

13. Project Management:


Question: How would you automate the creation of project
tasks in ServiceNow?
Answer: We can automate the creation of project tasks in
ServiceNow by configuring project templates and
workflows. Here's a sample script that creates project tasks:

```javascript
// Sample script to create project tasks
(function() {
var project = new GlideRecord('pm_project');
project.initialize();

// Set project field values


project.name = 'New Project';
project.description = 'Description of the new project';

project.insert();

// Create project tasks


var task1 = new GlideRecord('pm_project_task');
task1.initialize();
task1.project = project.sys_id;
task1.name = 'Task 1';
task1.insert();

var task2 = new GlideRecord('pm_project_task');


task2.initialize();
task2.project = project.sys_id;
task2.name = 'Task 2';
task2.insert();
})();
```

14. Vendor Management:


Question: How would you automate the vendor evaluation
process in ServiceNow?
Answer: We can automate the vendor evaluation process in
ServiceNow by configuring vendor evaluation forms and
workflows. Here's a sample script that triggers the vendor
evaluation:

```javascript
// Sample script to trigger vendor evaluation
(function() {
var vendor = new GlideRecord('vendor');
vendor.initialize();

// Set vendor field values


vendor.name = 'ACME Corp';
vendor.contact = 'John Smith'; // Set the appropriate
contact

vendor.insert();
gs.addInfoMessage('Vendor evaluation triggered for
vendor: ' + vendor.name);
})();
```

15. Financial Management:


Question: How would you automate the calculation of
financial metrics in ServiceNow?
Answer: We can automate the calculation of financial
metrics in ServiceNow by configuring financial management
formulas and schedules. Here's a sample script that
calculates the total cost:

```javascript
// Sample script to calculate total cost

(function() {
var costItem = new GlideRecord('fm_cost_item');
costItem.initialize();

// Set cost item field values


costItem.name = 'New Cost Item';
costItem.amount = 100.00; // Set the appropriate amount

costItem.insert();

gs.addInfoMessage('Total cost: ' + costItem.amount);


})();
```

16. Event Management:


Question: How would you automate the correlation of
events in ServiceNow?
Answer: We can automate the correlation of events in
ServiceNow by configuring event correlation rules and
workflows. Here's a sample script that correlates events:

```javascript
// Sample script to correlate events
(function() {
var event1 = new GlideRecord('em_event');
event1.initialize();

// Set event field values


event1.name = 'Event 1';
event1.insert();

var event2 = new GlideRecord('em_event');


event2.initialize();

// Set event field values


event2.name = 'Event 2';
event2.insert();

// Correlate events
if (event1.name == event2.name) {
gs.addInfoMessage('Events correlated: ' + event1.name + '
and ' + event2.name);
} else {
gs.addErrorMessage('Events not correlated.');
}
})();
```

17. Reporting and Analytics:


Question: How would you automate the generation of
reports in ServiceNow?
Answer: We can automate the generation of reports in
ServiceNow by configuring scheduled report jobs. Here's a
sample script that schedules a report job:

```javascript
// Sample script to schedule a report job
(function() {
var report = new GlideRecord('sys_report');
if (report.get('name', 'My Report')) {
var reportJob = new GlideRecord('sysauto_report');
reportJob.initialize();

// Set report job field values


reportJob.report = report.sys_id;
reportJob.name = 'Scheduled Report Job';
reportJob.run_time = gs.nowDateTime();

reportJob.insert();

gs.addInfoMessage('Report job scheduled: ' +


reportJob.name);
}
})();
```

18. IT Operations Management:


Question: How would you automate the monitoring of
infrastructure resources in ServiceNow?
Answer: We can automate the monitoring of infrastructure
resources in ServiceNow by configuring monitoring probes
and alerts. Here's a sample script that triggers a monitoring
probe:

```javascript
// Sample script to trigger a monitoring probe
(function() {
var probe = new GlideRecord('cmdb_probe');
probe.initialize();

// Set probe field values


probe.name = 'Monitoring Probe';
probe.target = 'localhost'; // Set the appropriate target

probe.insert();
gs.addInfoMessage('Monitoring probe triggered: ' +
probe.name);
})();
```

19. IT Service Management:


Question: How would you automate the fulfillment process
for service requests in ServiceNow?
Answer: We can automate the fulfillment process for service
requests in ServiceNow by configuring request fulfillment
workflows and tasks. Here's a sample script that triggers the
fulfillment process:

```javascript
// Sample script to trigger the fulfillment process for a
service request
(function() {
var request = new GlideRecord('sc_request');
request.initialize();

// Set request field values


request.requested_for = gs.getUserID(); // Set the
appropriate requested_for user
request.requested_item =
'1234567890abcdef1234567890abcd'; // Set the appropriate
requested_item

request.insert();

gs.addInfoMessage('Fulfillment process triggered for


request: ' + request.number);
})();
```

20. Cloud Management:


Question: How would you

automate the provisioning of cloud resources in


ServiceNow?
Answer: We can automate the provisioning of cloud
resources in ServiceNow by configuring cloud provisioning
workflows and templates. Here's a sample script that
triggers the provisioning process:

```javascript
// Sample script to trigger the provisioning of cloud
resources
(function() {
var provision = new
GlideRecord('cmdb_ci_cloud_provision');
provision.initialize();

// Set provision field values


provision.name = 'Cloud Provision';
provision.template = 'AWS'; // Set the appropriate cloud
template

provision.insert();

gs.addInfoMessage('Cloud provisioning triggered: ' +


provision.name);
})();
```

21. Incident Problem Integration:


Question: How would you automate the creation of
problem records from incidents in ServiceNow?
Answer: We can automate the creation of problem records
from incidents in ServiceNow by configuring incident
problem integration rules. Here's a sample script that
creates a problem record from an incident:
```javascript
// Sample script to create a problem record from an incident
(function() {
var incident = current; // Assuming the incident data is
available in the 'current' object

var problem = new GlideRecord('problem');


problem.initialize();

// Set problem field values based on the incident


problem.short_description = 'Problem from Incident: ' +
incident.number;
problem.description = 'Incident details: ' +
incident.description;
problem.category = incident.category;
problem.subcategory = incident.subcategory;
problem.impact = incident.impact;
problem.urgency = incident.urgency;

problem.insert();
gs.addInfoMessage('Problem record ' + problem.number + '
created from incident ' + incident.number);
})();
```

22. Change Incident Integration:


Question: How would you automate the creation of
incidents from changes in ServiceNow?
Answer: We can automate the creation of incidents from
changes in ServiceNow by configuring change incident
integration rules. Here's a sample script that creates an
incident from a change:

```javascript
// Sample script to create an incident from a change
(function() {
var change = current; // Assuming the change data is
available in the 'current' object

var incident = new GlideRecord('incident');


incident.initialize();

// Set incident field values based on the change


incident.short_description = 'Incident from Change: ' +
change.number;
incident.description = 'Change details: ' +
change.description;
incident.category = 'Hardware'; // Set the appropriate
category
incident.subcategory = 'Network'; // Set the appropriate
subcategory
incident.impact = 2; // Set the appropriate impact level
incident.urgency = 2; // Set the appropriate urgency level

incident.insert();

gs.addInfoMessage('Incident ' + incident.number + '


created from change ' + change.number);
})();
```

23. Incident Knowledge Integration:


Question: How would you automate the linking of
knowledge articles to incidents in ServiceNow?
Answer: We can automate the linking of knowledge articles
to incidents in ServiceNow by configuring incident
knowledge integration rules. Here's a sample script that
links a knowledge article to an incident:

```javascript
// Sample script to link a knowledge article to an incident
(function() {
var incident = current; // Assuming the incident data is
available in the 'current' object

var knowledgeArticle = new GlideRecord('kb_knowledge');


knowledgeArticle.get('number', 'KB0012345'); // Set the
appropriate knowledge article number

var knowledgeLink = new


GlideRecord('kb_knowledge_task');
knowledgeLink.initialize();

// Set knowledge link field values


knowledgeLink.kb_knowledge = knowledgeArticle.sys_id;
knowledgeLink.task = incident.sys_id;

knowledgeLink.link_type = 'Task';
knowledgeLink.insert();

gs.addInfoMessage('Knowledge article ' +


knowledgeArticle.number + ' linked to incident ' +
incident.number);
})();
```

24. Event Incident Integration:


Question: How would you automate the creation of
incidents from events in ServiceNow?
Answer: We can automate the creation of incidents from
events in ServiceNow by configuring event incident
integration rules. Here's a sample script that creates an
incident from an event:

```javascript
// Sample script to create an incident from an event
(function() {
var event = current; // Assuming the event data is available
in the 'current' object

var incident = new GlideRecord('incident');


incident.initialize();

// Set incident field values based on the event


incident.short_description = 'Incident from Event: ' +
event.name;
incident.description = 'Event details: ' + event.description;
incident.category = 'Hardware'; // Set the appropriate
category
incident.subcategory = 'Network'; // Set the appropriate
subcategory
incident.impact = 2; // Set the appropriate impact level
incident.urgency = 2; // Set the appropriate urgency level

incident.insert();

gs.addInfoMessage('Incident ' + incident.number + '


created from event ' + event.name);
})();
```

25. Problem Knowledge Integration:


Question: How would you automate the linking of
knowledge articles to problems in ServiceNow?
Answer: We can automate the linking of knowledge articles
to problems in ServiceNow by configuring problem
knowledge integration rules. Here's a sample script that
links a knowledge article to a problem:

```javascript
// Sample script to link a knowledge article to a problem
(function() {
var problem = current; // Assuming the problem data is
available in the 'current' object

var knowledgeArticle = new GlideRecord('kb_knowledge');


knowledgeArticle.get('number', 'KB0012345'); // Set the
appropriate knowledge article number

var knowledgeLink = new


GlideRecord('kb_knowledge_task');
knowledgeLink.initialize();

// Set knowledge link field values


knowledgeLink.kb_knowledge = knowledgeArticle.sys_id;
knowledgeLink.task = problem.sys_id;
knowledgeLink.link_type = 'Task';
knowledgeLink.insert();

gs.addInfoMessage('Knowledge article ' +


knowledgeArticle.number + ' linked to problem ' +
problem.number);
})();
```

These are just examples of how you can automate various


scenarios in ServiceNow using scripting. The actual
implementation may vary depending on your specific
requirements and configurations.

You might also like