Universal Use Cases Documents - ServiceNow
Universal Use Cases Documents - ServiceNow
When Story record is created then it should automatically create 4 different scrum tasks
records of development, testing, analysis and documentations.
Scenario2: There should be a field on problem form which should show the number of
incident records associated with the same problem.
Scenario3: If all the catalog tasks requests are closed completed then request item should
automatically closed.
Scenario4: user should not be able to resolve the incident if change record mentioned in
change request field is not closed.
Scenario5: if users updates work notes of problem task then it should update same work
notes in parent problem record as well with highlighting problem task number.
a.copy('sc_req_item',current.sys_id,'sc_task',gr.sys_id);
}
}
})(current, previous);
Scenario7: Prevent duplicity- Prevent user to raise an incident if a already exists incident
with same caller and same short description
Scenario8: Check task status for RITM – prevent user to mark a RITM closed complete if
related task are not closed. Also display task hyperlink in the information message.
Scenario10: As a Developer I want the KB article author name change to knowledge base
manager when the author is leaves the organization so that all are articles have active
authors.
1. When a "Change Request" is in the "Review" state and is marked as "Rejected,"
automatically set the state of all related tasks to "Cancelled."
2. For any incident that is updated to the "Resolved" state, check if there are other incidents
with the same "Caller" that are in the "On Hold" or "In Progress" state. If such incidents
exist, automatically update their work notes to indicate the resolution of the related
incident and link them together.
3. Implement a rule that when a new "Service Catalog Request" is submitted with a high
priority , it checks for any open incidents from the same user in the past 30 days. If more
than three such incidents are found, change the priority of the new request to "Priority 2" .
5. Write Business Rule that prevents deletion of any "Problem" records if there are active
related incidents.
6. Create a Scheduled Script Execution that runs daily to check for incidents that have been
in "New" state for more than 7 days and send a reminder email to the assigned user.
7. Implement a GlideAjax script to fetch and display the number of open incidents for a
specific assignment group on a form.
8. Write a Client Script to dynamically populate a "Related Incidents" field based on the
selected Configuration Item in an Incident form.
9.Write a script that dynamically validates the "Planned Start Date" and "Planned End Date"
fields on a Change Request form to ensure the start date is not in the past and the end date
is after the start date. If the validation fails, display an appropriate error message and
prevent the form submission.
10.Write a script to automatically populate the "Assigned To" field with the manager of the
user who created the incident when the incident's priority is set to "High". Ensure that if the
manager information is not available, an appropriate error message is displayed, and the
field remains empty.
11.Create a script that ensures the "Short Description" field on a Task form is dynamically
updated to include the current date and time whenever the "State" field is changed. Ensure
that the format of the date and time follows the pattern "YYYY-MM-DD HH:MM".
13. Create Problem from Incident, when "Create Problem" button is clicked and re-direct to
Problem record created.
14. Make assignment group and assigned to fields editable only to Admin and ITIL. For
others these fields should be readonly.
15. Create Notification using flow. Assigned To should get notified when the Incident is
resolved.
16. Print "<Incident Number> : <Short Description>" into log when Incident is saved.
} }
function onAfterInsert(current) {
// Check if the assigned group field is populated if (current.assigned_to != '') {
} }
getActiveIncidents: function(userId) {
var incidentGr = new GlideRecord('incident'); incidentGr.addQuery('assigned_to',
userId); incidentGr.addQuery('state', '!=', 7); // Not Closed incidentGr.query();
};
incidents.push(incident);
}
return JSON.stringify(incidents);
}
};
};
} };
} };
};
data.push(item);
}
gs.info('Data retrieved successfully.');
return data;
} catch (e) {
gs.error('Error retrieving data: ' + e.getMessage());
return null;
}
In this example, we've added logging statements using gs.info() to track the execution of the
script. We've also wrapped the code in a try-catch block to catch any errors that may occur. If an
error occurs, we log the error message using gs.error().
return sum; }
};
Script Objective: Write a business rule that triggers on the incident table. The rule should
fire only if the incident priority is 'High' and the incident category is 'Network Issue', but not
if the incident state is 'Closed'.
Challenge: Ensure the script includes complex conditions, handles different scenarios, and
performs actions like sending notifications or updating fields.
Script Objective: Create a Script Include that provides reusable functions for calculating SLA
times. Include methods to calculate the remaining SLA time, the elapsed time, and to
determine if an SLA is breached.
Challenge: Ensure the Script Include is efficient, follows best practices, and can be called
from various Business Rules or Client Scripts.
Script Objective: Develop a client Script that uses GlideAjax to call a Script Include and
retrieve data based on user input. The client script should dynamically populate a field on
the form based on the data received from the server.
Challenge: Handle asynchronous data retrieval and ensure that the UI updates smoothly.
Address potential issues with data synchronization and error handling.
Script Objective: Create a Scheduled Job that runs every night at midnight. The script should
identify all incidents older than 30 days and automatically update their state to 'Resolved', if
they are in 'In Progress' or 'On Hold' states.
Challenge: Implement efficient query handling, ensure proper logging of actions, and handle
exceptions that may arise during the execution.
Script Objective: Design a Service Catalog item that initiates a custom workflow. The
workflow should include multiple approval stages, conditional tasks based on user input, and
an automated email notification at each stage.
Challenge: Create complex workflow logic, handle approvals dynamically, and ensure
integration with the Service Catalog.
Script Objective: Develop a script to integrate with an external REST API. The script should
retrieve data from the API and create or update records in a custom table in ServiceNow
based on the response data.
Challenge: Handle authentication, manage API rate limits, and ensure proper error handling
and data mapping.
Script Objective: Write a GlideRecord script that performs a complex query on the
change_request table. The script should return records where the change request is of type
'Emergency', has a priority of 'Critical', and has been assigned to a specific group.
Challenge: Optimize the query for performance, handle large datasets, and process the
retrieved records efficiently.
Script Objective: Create a Data Transformation script to import data from a CSV file into
ServiceNow. The script should map fields from the CSV to the appropriate fields in the
cmdb_ci_computer table and handle any data validation or transformation needed.
Challenge: Ensure accurate data mapping, handle different data types, and manage
potential data transformation errors.
Script Objective: Develop a script to automate user role assignments based on specific
criteria. For example, assign a particular role to users based on their department or location
in the user profile.
Challenge: Handle role assignments efficiently, manage exceptions, and ensure that role
changes are accurately reflected in the user's profile.
Script Objective: Write a GlideRecord script to aggregate data from the incident table. The
script should calculate the average resolution time per category and return the results in a
formatted output.
Challenge: Implement data aggregation and calculations, handle large datasets, and ensure
that the results are accurate and well-presented.
Validate form where you need to check whether user id exists or not or whether a user is having a
valid email domain or not.
Create a Catalogue item where request for will be auto populated with the logged in user id.
Create a script to fetch and display related records using Glide Record.
Display a list of incidents as per logged in user's location with incident location.
Write a script to get the list of active incident records which are assigned to currently logged in
users and get them in priority list view.
Try to use error handling try/catch block and scripting best practices to optimize the performance
Whenever caller id is ''Newton Sacs '', make assignment group as mandatory, but it should not be
valid for other users.
Take input from user and update a custom field name as "name".
Auto populate - email, assignment group, company with respect to caller id on an incident table.
Make 4 utility in a script include function [sum, difference, multiply, divide ] and call them
anywhere and showcase the output
Create a utility Script Include containing 4 functions to create, update, read and delete records on
any table which is passed as an argument from the user dynamically. And the queries will also be
passed as a parameter dynamically.
Scenario: A user reports that they are unable to access a critical business application.
Details: The IT service desk receives the incident ticket and assigns it to a support technician.
The technician troubleshoots the issue, identifies the root cause (e.g., server outage), and
resolves it within the agreed-upon SLA.
Service Request Fulfillment
Release Management
Scenario: The development team prepares to deploy a
new version of a web application.
Details: The release manager creates a release plan
outlining tasks, timelines, and dependencies. They
coordinate with development, testing, and operations
teams to schedule deployment activities. The new
version undergoes testing in a staging environment
before being rolled out to production.
Service Level Management
Capacity Management
Access Management
Network Outage
Scenario 1:
When a change request is completed, send an email to the assigned to person on all
related problems and incidents informing of the closure.
Scenario 2:
There exists 3 groups : TEST.GRP1, TEST.GRP2, TEST.GRP3. Whenever the Group
manager of these groups is updated (even from NULL), add all those updated users
(managers) in a new group TEST.MGR_GRP
Scenario 3:
On linking, removal or updating the reference field Problem on an incident, post a
work note on the problem record.
1.
2. Incident <Inc_number> is now linked to the problem.
3. Incident <Inc_number> is no more linked to this problem.
4. Incident <Inc_number> is newly linked to the <newPRB_Num> from
<oldPRB_Num>
5. Make sure a work note is posted in every kind of update done to the problem
field on incident.
Scenario 4:
On a OOTB copied incident, display a info message which shows the fields being
copied (not the values), check the incident being a copied incident on a script
include call.
Scenario 5:
Auto-populate new incident form:
certification date,
ServiceNow certificate - True/false
Requested for (auto-populates with logged in user name),
Certification name (choice list),
Addl. info (String),
Certification cost (Numeric field), abort submission with alert message, if not
numeric.
Checks:
Scenario 9:
Display an info message on a incident informing the user, the duration since the
incident is in open state. When it is the Assigned to of the incident viewing the
incident, the info message should read the SLA Breach time left.
Scenario 10:
Import incident data into ServiceNow, with Category and Short description
inputs provided from an excel (external source).
Caller is auto-populated according to one of the above scenarios.
Using a transform map,
o Apply a template A (already created) to prefill all fields that you wish
to, if category selected is A and short description contains a keyword
(choose your own)
o Else pre-fill only the mandatory fields on the incident with fixed values.
Question: 15
Write a reverse array in background scripts 'Reddeppa' (string)?
Script :
Explanation:
split(''): Converts the string 'Reddeppa' into an array of characters.
reverse(): Reverses the array of characters.
join(''): Joins the reversed array back into a string.
gs.info(reversedName): Logs the reversed string 'appeddeR' to the
system logs.
Problem : Remove duplicate from array and replace with some value
Input = [1, 2, 3, 2, 4, 5, 4, 5];
Output = [1, 2, 3, 4, 5, -1, -1, -1];
Code :
var array = [1, 2, 3, 2, 4, 5, 4, 5];
var dupArray = [];
var combinedArray = [];
for (var i = 0; i < array.length; i++) {
for (var j = i + 1; j < array.length; j++) {
if (array[i] === array[j]) {
dupArray.push(array[j]); // Insert duplicate in new array
array.splice(j, 1); //Remove duplicate from main array
}
}
}
var addValue = -1;
var index;
for (var k = 0; k < dupArray.length; k++) {
index = dupArray.indexOf(dupArray[k]); //get the index of element
from duplicate array
dupArray[index] = addValue; // Replacing duplicate element with
value
}
//gs.print(dupArray);
combinedArray = array.concat(dupArray);
gs.info("Output : "+combinedArray);
gs.log('====== join======');
//The join() method returns the array as a string.
gs.log(fruits.join());
//*** Script: Banana,Orange,Apple,Mango,Kiwi
gs.log('====== toString======');
//The toString() method returns a string with all the array values,
separated by commas.
var x = fruits.toString();
gs.log(x);
//*** Script: Banana,Orange,Apple,Mango,Kiwi
while(duplic.next()) {
array.push(duplic.getValue("name"));
}
while (grw.next()) {
tempArray.push(grw.getValue('name'));
tempArray.push(grw.getValue('serial_number'));
old_computers_all.push(tempArray);
}
I need to create an array using values from a custom table in script
step and use its values as outputs for further flow. But I am not sure
how to do so..
})(inputs, outputs);
-----
You must assign the value of the step output variable to the output
variable in the Outputs section of the action.
===================================
variablesToCheck.split(',').forEach(function(varName){
if (current.variables[varName] == 'Yes') {
tasksToCreate.push(varName);
}
});
while ( gr.next() ) {
// Create SC Task
var scTask = new GlideRecord('sc_task');
scTask.initialize();
scTask.setValue('request_item', current.sys_id);
scTask.setValue('short_description',
gr.getValue('CUSTOM_SHORT_DESC_FIELD_NAME'));
scTask.setValue('description',
gr.getValue('CUSTOM_DESC_FIELD_NAME'));
scTask.insert();
while (gr.next()) {
if (current.variables[gr.getValue('u_var_name_field_here')] &&
current.variables[gr.getValue('u_var_name_field_here')] == 'Yes') {
// Create SC Task
var scTask = new GlideRecord('sc_task');
scTask.initialize();
scTask.setValue('request_item', current.sys_id);
scTask.setValue('short_description',
gr.getValue('CUSTOM_SHORT_DESC_FIELD_NAME'));
scTask.setValue('description',
gr.getValue('CUSTOM_DESC_FIELD_NAME'));
scTask.insert();
}
}
getRoles: function(){
//Retrieve roles
var croles = new GlideRecord('u_lawson_company_codes');
croles.addQuery('u_inactive',false);
croles.query();
},
type: 'TestApps'
});
function onLoad() {
var tlist=[];
function returnCodes(response){
var answer =
response.responseXML.documentElement.getAttribute("answer");
alert("Answer: " + answer);
tlist=answer;
}
=================================
𝟭. 𝗺𝗮𝗽()
- Creates a new array by applying a function to each element.
```
const numbers = [1, 2, 3];
const doubled = numbers.map(num => num * 2);
console.log(doubled); // [2, 4, 6]
```
𝟮. 𝗳𝗶𝗹𝘁𝗲𝗿()
- Creates a new array with elements that pass a test.
```
const ages = [16, 21, 18];
const adults = ages.filter(age => age >= 18);
console.log(adults); // [21, 18]
```
𝟯. 𝗿𝗲𝗱𝘂𝗰𝗲()
- Reduces an array to a single value.
```
const sum = [1, 2, 3].reduce((acc, val) => acc + val, 0);
console.log(sum); // 6
```
𝟰. 𝗳𝗶𝗻𝗱()
- Returns the first element that satisfies a condition.
```
const users = [{ name: "John" }, { name: "Jane" }];
const user = users.find(u => u.name === "Jane");
console.log(user); // { name: "Jane" }
```
Hi All,
Hope you have come across a scenario where you perform certain use
cases on ARRAYS like
2. find difference between two array's and what is the difference value
var a1 = [12,13,56,15,178,23,21];
var a2 = [12,14,56,15,178,24,25];
var tst = new ArrayUtil().diff(a1,a2);
gs.info(tst);
// Array Utils
gr.addQuery('sys_id',arr[i]);
gr.query();
if(gr.next()){
gr.last_run_datetime = '';
gr.update();
Arrays
Think of arrays as your trusty sidekick when it comes to organising data in
ServiceNow. They're like numbered lists that can hold all sorts of stuff – from incident
IDs to user names and everything in between. With arrays, you can keep things in
order, access them by their position, and even have duplicates if needed.
When to Reach for Arrays:
1. Ordered Data: If you need to keep things in a particular order – like
processing incidents in the order they were created – arrays are your go-to
choice.
2. Easy Access: When you find yourself reaching for data by its position in the
list, arrays make it a breeze.
3. Duplicates Welcome: Need to store the same value multiple times? No
problem! Arrays are happy to oblige.
Sets
Now, let's talk about sets – the neat freaks of the data world. Sets are all about
keeping things unique and tidy. They don't care about order – they just want to make
sure there are no duplicates hanging around. If you need to compile a list of unique
values, sets are your best friends.
When to Choose Sets:
1. Unique Values Only: When you need to ensure there are no duplicates in
your collection, sets have got you covered.
2. Quick Checks: If you find yourself constantly asking, "Is this value already in
the list?" sets can give you a lightning-fast answer.
3. Order Be Damned: Who needs order anyway? Sets don't care about the
order of things – they just want to keep it clean.
Use cases
On form two dates field , if data1 is not equal to
1
date2 the string field should populate.
If there is a custom field on click of UI action I
want to populate count of incident which are
2 from same assignment group and I want to show
this field to only admin or ITIL user which
modules you will use for this?
If there are client A and client B, Client A should
not see applications for client B and vice versa
3
how you will do this other than domain
separation?
If there is 4 variables on service catalog, i want
4 to auto populate 3 variables on the basis on 1
variable. How will you achieve?
There is incident form. On incident form there is,
on hold field & on hold reason field. If caller
5
added any comments on incident, the incident's
state will be in progress. How will you achieve?
6 There is incident form. On incident form there is,
incident task related list. On incident task
related list there is new & add UI action. I want
to show that ui action if incident is in in progress
state. How will you achieve?
I want to move list of incidents from 1
7 development instance to UAT instance. It is in
GB size. How will you transfer?
There is custom table, in that there is 2 fields.
User_id & email_id. I want to update the record if
8
email_id is empty. Which coalesce condition you
will apply?
What is the Backend table name of business
9
rule, ACL, reports?
if we already discovered one particular machine
10 and if we again try to discover it in which phase
of discovery will start.
There is a catalog item variable ‘Requested for’ ,
11 I want to populate logged in user’s name in that
field .
Catalog item status if not completed then wait 5
min to approve and if manager does not
12 approve then again wait for 5 min for another
approval if he does not approve then status will
be changed to on-hold?
Suppose we are creating catalog task and we
want to create one type of task for employees
related to A company and different task for
13
employees related to B company and different
task for employees related to C company how
we can do this.
There is table Location with field (building name,
city, street etc).
14
In service catalog when you select location field
you need to auto populate building name.
Suppose there are 2 tables Location & Building.
15 Now when you are selecting location you need
to display Buildings under that location.
Write a script to calculate the time taken from
16 ‘new’ to ‘in progress’ state of incident and
display on form field.
Suppose there are 5 groups A,B,C,D,E.on submit
of incidents, on user table if summary contains
17
string AD And location is A then assign group A
to user(do same for all groups).
I have a excel sheet containing 100-200 records
and I want to perform
validations before transforming. Each and every
18
record must pass all the validations if a single
record
fails no record should be entered.
There is variable in service catalog which only
19 should be visible to user which are from India
location.
20 There is a flat file of excel sheet present we
need to populate 100 computer records from
this excel sheet into our ServiceNow CMDB and
there is one link field present in each record
which should be an attachment into our
ServiceNow system records and it should
download that attachment from the link if IP of
the location given.
The CMDB Tables are in relationship with
cmdb_ci>application>business application, I
21
need to populate the service on incident form
based on CI's parent .
I want to auto populate callers mail id in email
22
field?
Based on Assignment group auto populate the
23
users.
How to get the current and previous values of
24
field .
IF user is not member of Service Desk Group
25
then Cancel the form submission?
ACL Scenario:role:1)admin2)normal user; only
26 admin can edit fields of table normal user can
read.
If incident is created by logged in user it should
27
be only visible for that user?
How to create record on specific date
28
automatically on incident form?
29 write down script to create a task.
If you have 10 same variables on different
30
catalog items will you create on each item?
In a catalog item there are two variables, both
variables refer to same table. I want to show one
column data of the referenced table in variable1
31
and at the same time want to show another
column data of the referenced table in
variable2.
If I have an array in Run Script activity which
consists of 3 different user email ids and I want
32
to send notifications to those 3 users? How can I
achieve it?
There is 1 catalog item, on that there are 4
33 fields. 1 field is requested by, on the basis of
this I want to populate other details of user.
There is incident form. On that record problem is
attached. If problem is attached then name of
34
the problem will populate in description field of
incident.
There is incident table. I want count of the
35
incidents using background script.
If I want to make a field mandatory and also it
36
should not be empty then what should I use?
How will you allow specific users to write in an
37
incident field?
After selecting a caller, manager of the caller
38
should auto populate in the below field.
I want to give write access to manager field to
39
an end user, how will you achieve this?
40 write a code to get the date values of start date
and end date fields on incident form and set an
error message if the start date is greater than
end date.
If in user table there is a field ‘type ‘ in which
there are 3 types A,B,C each user is given a type
41
, now if type A user logs in he should be able to
see only type A users how will you achieve this.
If there are 3 approvals. All procedure
implemented and moved to production. Again
42 client requirement come and he told remove
2nd approval. when again implemented this
requirement what n how the process will be?
When I am opening a new form of incident, then
I want to show only specific 5 fields on the form.
43
And when the form is submitted, then form will
be open in default view. How to achieve this?
I am opening incident form. And there is Caller
44 field on it. And there is 1 UI action show related
incidents. What it called as?
Convert string field to date field while
45
transforming data.
1. Make an ITIL user see the “additional comments” label as “additional
comments (customer visible)”. For rest all it must be 'Additional Comments'.
(Done via Client Script)
2.
3. Make 'assigned to' mandatory if 'assignment group' is populated (Use Client
script)
3. Make the state to 'In Progress' from 'New' if the 'assigned to' gets populated from
empty to some value. Also, flash the state variable for 3 to 4 seconds to mention the
logged in user that the value is changed and it is in In Progress state. (Use client
script)
Create a UI action named Transform as request. This UI action is only visible for
users with a role starting by Outsource and request.status is open or assigned or
work in progress. A popup should ask for confirmation.
I had tried but i got a troubles with triggering (it's not created, i think becouse after specialist click SAVE - the
SLA is already completed and so it's not displayed at all.
I had tried to add the stop condition to pause condition and create some business rules that will change state of
sla to complete - it helps, but i got a lot of bugs after this (SLA repair button doesn't works correctly and ect). So
need a clever one :)
Answers: You could set your stop condition as a pause condition instead.
For example:
Start when active is true - set retroactive start to opened
Pause when created on is not empty.
This way you'll get some SLA's to start up. However you're left with SLA's that are paused. It that's OK, then
you can just mark the stop condition as active is false so that they'll be completed when the ticket is closed.
Answers:
to answer you question, generally in upgrade, tables matadata doesn't change. You should be fine with columns
length changes.
Just a note : be caution about changing columns length more that 255. A table should not have more than 10
columns with max length 255, this is a mysql innodb imitation.
Issue#3 Scripted rest to update only fields that are changing?
Hi All,
Can someone please help me with some logic and advice on how to update only some fields which have been
updated/changed in the other 3rd party tool(servicenow).and keep the other fields unaffected.
Although, we are getting the request from 3rd party with all the the mapped fields, BUT with every inbound
requests it is updating every field with the same value.For example, even if short description value is "test abc"
initially, it again gets updated to "test abc",once the next inbound comes (which is the same).
Also to note, if the request doesnt send us all the mapped fields ,for obvious reasons i would get code error
while processing the script.
Answers:
Partial update can be done via patch method. Please use patch method to update the resource.
Issue#4 Insert/Send multiple attachments through REST API in
scoped application
Hi All,
I am posting this here as i couldn't find sufficient information over the internet.
Requirement:
Integration of two servicenow instance to send and recieve multiple attachments on INCIDENT module.
Problem Summary:
Of the two ,one instance is having incident in scoped application, thus most of the global scripts(OOB) are
duplicated in scope to facilitate the smooth operations. The latter one may or may not be in scope.
Now as we are aware REST is itself in global application(Correct me if I am wrong),thus most of the
functionality are not going to work. Stating that,we can say basic scripts syntax like GlideSysAttachment might
not work.
So,
1. How to make implement that functionality,i.e Sending and inserting attachment on the target incident on the
other instance.Please provide a code snippet or reference URLs if you can, for better understandings.
2. Also, which method should we use Data Serialization or Data Streaming.
Answers:
i took help from the saveResponseBodyAsAttachment function from the docs, which easily helped on every
insert.
Issue#5 Making an outbound REST call (GET) from inside an
inbound scripted REST API (POST)
I have an incoming webhook with some data(say name) and a link(1). I created a scripted rest api which takes
that name and inserts a record with that name as a field.
Now i also want to make a GET call to that link(1) to get the rest of the data. Any way to do this properly short
of sending the link content as data in the first place(difficult at this moment).
Answers :
So the link1 is an external end point? if not why dont you try fetching the records using gliderecords and pass
it in response?
or maybe a long process of creating multiple get and post api endpoints.
eg.
say your snow url is first accessed,by snowURI1->it fetches record of the external link1->sets the response
body.
Answers:
Is this workflow will run if user creates a Request or user run this workflow on demand?. Because, alert is a
client side function and workflow supports only server side scripts. You may follow below process. Run the
powershell activity get the requierd output in json or something and parse the output update worknotes of the
ticket, create an approval to a concerned person ask him to check worknotes if he approves then process next
steps otherwise end the workflow and cancel the request
Issue#8 Load data periodically and insert records?
Hi All,
I have couple of questions:
- I get a file periodically with some data from which I should create requests.
- I would like to understand , where should this file be placed and How should I consume the file to create
requests.
Many Thanks.
Answers:
Hi,
You can use FTP type data source to retrieve a file copied to a folder in server. Navigate to system importsets --
> Data sources click new and you can try the different type of retrieval method by selecting an appropriate "File
Retrieval Method"
(new sn_assessment_core.AssessmentCreation()).conditionTrigger(current,
'249e70b0875013005d90bba826cb0bbf');
}
Answers:
This is a system generated business rule for trigger condition you have defined for assessment, If this BR is
deactivated then survey/assessment will not get triggered
Issue#10 IT Onboarding Process?
Goal:
I'm looking for a way to implement employee IT onboarding at our company. I'd like to share my thoughts and
hopefully can get some good ideas from this community on the best way to implement in ServiceNow.
Today:
HR completes an on-line form when a new employee is hired and the page sends an email to mail group
requesting action. Recipients get basic info and begin creating user accounts and etc.
Supervisors then complete a paper form with more specific hardware/software requirements for the new hire.
Future:
The on-line form HR uses today could be modified to send an email to ServiceNow. ServiceNow could parse
the fields and begin building a request. Ideally the supervisor would receive a request that looks like the order
guide with all basic employee information pre-filled. The supervisor could select hardware/software
requirements and all catalog items would be fulfilled by the appropriate team.
I don't know how to save the order guide so that the supervisor could continue the process. Any ideas greatly
appreciate
Answers:
HR Lifecycle Events Cases shows all cases and child cases related to life-cycle events.
You can also view Lifecycle Events cases in the HR Cases list. Refer to Finding HR cases.
The quickest way to find cases assigned to you is to use the HR Service Portal. Refer to Using Employee Service
Center to view your cases.
To create, edit, or track a Lifecycle Events case, refer to Work an HR case.
Once a case is created or modified, under Related Links, there are links unique to Lifecycle Events cases:
Requested user actions: Shows a list of user actions from the new-hire check list with links to the tasks.
Activity Set Execution: Shows all activity sets for a life-cycle event.
Show Workflow: Displays the workflow associated with the Activity Set.
Create or modify a Lifecycle Events case
HR Lifecycle Events cases contain HR activity sets that contain trigger activities.
Issue#11 Issuing Demand Assessments to customers in
different domains than the domain in which the demand
resides.?
Looking for expertise in the following:
Domain Separation
Sending Assessments to stakeholders in other domains
BACKGROUND
We have a domain separated environment. We operate in a domain beneath the Global domain just like any
other client does. Our service offerings to clients are different depending on what they wish to purchase (Gold,
Silver, Bronze).
Our domain structure looks a bit like this:
Global
o Top
o
Our Domain
Gold Customers
Client A
Client B
Silver Customers
Client C
Client D
Bronze Customers
Client E
Client F
Within Our Domain, Ideas are converted into Demands, some of which will be implemented in a domain that
will affect clients in other domains. We want to be able to send an assessment to stakeholders in domains that
may be impacted through the implementation of the demand.
For example: we may consider a demand to be implemented in the Gold Customer domain and want to send an
assessment to the stakeholders from Client A and Client B. We do not want Clients C, D, E, F to see the
demands or the assessments.
With the idea and demand residing in "Our Domain", how do we issue assessments to stakeholders in the Gold
Customers Domain?
Answers:
It is very tricky with the requirement what you have.
It has been very straight forward by granting visibility domain permission to users in customer domain to your
domain. But that will grant too much of the access.
Answers:
Priority field helps in determining the priority to be given for ASYNC business rules.
3. In Incident Management, create an "Affected CI" lookup field where columns (CI ID,
Class, Description) should be displayed
4. In Incident Management, notes should be mandatory when Urgency and Impact is
modified.
5. Urgency field in Incident management form, should be editable after the ticket is submitted
from both ESS and ITIL View until the ticket is moved to Resolved Status.
1. There should be an error message pop up displayed while saving the change ticket to
requester when he is also the only approver of that ticket.
2. In Change Management, the Planned Start Date and the Planned End Date. (Hint: If these
two fields are not available in change form, then create the same)
3. In Change Management, "Planning" tab should be mandatory while creating the change
ticket.
4. In Change Management, Requester will be notified, when change is been raised during
Moratorium period. (Hint: it means when user create change ticket at any specific period,
then user or requester will be notified through any pop-up message or through email, for
implementation you can consider any specific period for the same).
There are lots of ways to do that, you can do it from import xml, CSV or excel etc. So here
we are suggesting only one way that is through XML. Where we import XML from one
instance and export XML to another instance. There are few things which we need to take
care while doing this transaction. We will also cover those at the bottom of this page.
So, let’s say we have ServiceNow developer instance where we have a group along with
members and roles and now, we want to move this to ServiceNow Production instance.
** Please make sure to do all activities mentioned below, you should have admin roles.
So, first activity which are going to do is exporting the data into XML from one
instance that is ServiceNow Developer Instance:
You should check that what all user of the groups are available in the targeted
instance. Otherwise after importing the data in targeted instance those users will be
displayed as empty. So to populate those users you have to export those users XML from
user table and import the same in targeted instance user table. After doing this empty field
automatically replace with username because that empty record contains same user sys_id.
Same as above for roles. Roles should also be validated otherwise same activity has
to be done for roles as well.
Make sure that first import the group XML and then import members XML or roles
XML in targeted instance.
For the understanding of this topic we have posted a video on our you tube channel. Please
find the link below which will help you to understand this in details and in practical way.
So. to understand the Ci in cmdb in detail. Lets navigate to servicenow application. Please
follow below steps:
1. Navigate to ServiceNow development instance and type cmdb_ci.list (base table of cmdb)
in filter navigator available on left side and press enter.
2. It will open the cmdb_ci table list view as mentioned in below image. "cmdb_ci" is the
base table and all the CI classes in cmdb extend this base table by default.
so all the records displayed in list view are Ci records, Configuration item (cmdb_ci) table
contains all the CI's. Please click on the name which in displayed in list view such as
*ANNIE.
3. After you clicked on the name you will find page as displayed below, which show that CI
record store all the required information as I have mentioned in above definition.
In below image I have tried to display, that how CI in cmdb stores the information of the
Laptop available in organization.
So, in this way cmdb in servicenow provides an organized view of configuration data so
that the organization gains the full visibility of its infrastructure and services, leading to
more control of organization environment and better decisions.
There are some core features of cmdb, which helps to manage and maintain the
Configuration data and provides the required information of infrastructure components.
Core features of cmdb are:
CMDB Health
CMDB Identification and Reconciliation
CMDB lifecycle Management
CMDB baseline
I will post the separate blog to give an understanding of above core features. But below
content will provide required understanding of ServiceNow CMDB.
So let's see what is CI Class in cmdb, CI relationship in cmdb and how to create the CI
Class in cmdb.
CI class in cmdb is actually a table which extends any other table or extended by any other
table. Means a CI class can be parent table if extended by any other table or it can be child
table if it extend any other table. for e.g.
so above basically laptop table is a child table and hardware table is the parent of laptop
table but it is child table of configuration item table.
What is CI Relationship in ServiceNow?
When two CI's in cmdb have dependency on each other in any way then, we can say that
those two CI's have a relationship. In servicenow cmdb there are lots of relationship type,
such as cluster of (parent), stored on (child), uses (parent), runs (child) and many others etc.
So a relationship consist of two CI and a relationship type, please find below image for
understanding:
2. Once you clicked on CI Class Manager module, click on hierarchy as displayed in below
screenshot:
3. Select any Class under which you want to create your class or you want to extend the
class. Once you clicked the class you will find the "Add child Class" option on right side, if
the selected class extensible checkbox is checked.
4. Now click on Add Child Class and fill the required details as mentioned in screenshot
below and create the CI class in cmdb. for more information you can also see the cmdb
servicenow youtube video attached in this blog above.
So, now I think you are clear about the CI, CI Class, CI relationship and CMDB. Now let's
see that how the CI can be populated/created/stored in cmdb in servicenow. There are
different ways through which CI can be populated.
User can manually create or modify any CI in cmdb, as i have mentioned in below
screenshot by clicking on new button.
Through Microsoft SCCM integration you can import SCCM data into cmdb in servicenow.
But remember that you can only perform single direction import from SCCM to cmdb in
servicenow.
3. CMDB Discovery
Cmdb discovery is servicenow product and by using cmdb discovery you can import the
information into servicenow instance from another source and you can also integrate
servicenow cmdb with existing external cmdb. Cmdb discovery is widely used to populate
and manage the CI related data in servicenow cmdb.
So as we discussed above about cmdb discovery, let's see in detail that what is cmdb
discovery and what are the types of discovery.
What is Discovery?
Discovery finds computers, servers, printers, a variety of IP-enabled devices, and the
applications that run on them. It can then update the CIs in CMDB with the data it collects.
Discovery is an ITOM application and it is a paid plugin from servicenow.
Discovery runs on an on-demand or on scheduled basis to help ensure the accuracy of the
configuration item (CI) data underpinning ServiceNow applications across the enterprise
1. Horizontal Discovery
2. Top-Down Discovery
ServiceNow CI Relationships and ServiceNow CI Relationship Editor
In ServiceNow, the relationship between the configuration items has been captured by
Configuration Management Database. Means a database, where we have lots of CI, CI
Classes or we can say CI tables.
CI classes or CI table in CMDB contains CI's and those CI's having some
relationships.
Here the CI having a technical relationships with other CI such as Used by, Run On,
Consumes, Allocated to and many more etc.
Before we start create CI in CI class and create a relationship between them, let's first
understand what is a CI.
A CI is a record which include or contains all the relevant data or information of all the IT
assets a company have, such as Hardware, IP Address, Network, Warranty details, Software
License, Documentation and many more. CI stores, information such as manufacturer,
vendor, location, asset id, serial number, DNS etc.
CI information can be modified, added and deleted.
Some of CI Types are: Hardware, Software, Server, Clusters, Database
servers, IP Networks, Software licenses, Locations, Data center, VPN etc.
Relationship is basically the dependency of one CI to another CI and CI can have multiple
relationship. For e.g Software runs on Windows and Window install on Computer and
Computer use Server.
So, each CI relationship has a starting Point, target point and a verb. Where you can say that
starting point is parent CI and target point is Child CI vice versa and a verb is basically a
relationship type between both the CI's.
CI Relationship in ServiceNow
CI's can also have relationship with users and group. Below screenshot will provide you the
idea that from where in ServiceNow you can navigate and find the CMDB module.
Under relationship of configuration application you will find modules as displayed above.
Now as we done with CI and CI relationship understanding now let's understand that how
we can create the CI's relationship in cmdb and see the kind of relationship relationship CI's
have.
Below are the steps, from where we will create the CI from the scratch and then create a
relationship between the two CI's in cmdb servicenow.
Type configuration in left filter navigator and then navigate to server and then find
window.
Click on Window
Click on New Button
once you click on new button you will find below form, fill some information on fields
displayed in the form. Refer below image for the same.
CI Record in ServiceNow
Now save the record. In this way you have the created the CI record under window CI class.
Step 2:
Once you save the CI record, scroll little down, you will find option in related item section
as mentioned in below image:
Step 3:
Once you clicked on that icon, you will navigate to relationship editor page. Where
you can select the relationship type and also do filter to find out the required CI from whom
you want to create a selected relationship.
Scroll little down, now you can select the required CI as per as the filter applied by
you.
After selecting the CI click on addition symbol to add CI in relationship list as
mentioned in below images.
Now click on save or save and exit button. In this way CI relationship between two CI can
be created. A CI can have relationship with multiple CI's.
Now Let's see...
Step 1: Navigate to any CI Class and open any existing CI record, whom relationship you
have to check.
For e.g.
Navigate to Server --> Window--> open any existing CI --> here i am going to open the
CI, which we have created above.
scroll little below in related item you will the relationship we have created such as Runs
and Used by. Here in related list L1 is First line support and L2 is second line support.
Step 2: Now click on dependency view icon as displayed in above image. Once you clicked
you will find the hierarchy tree where you can see the relationship a CI have with other CI's.
I think from the above example we can come into conclusion that CI relationship in
cmdb provide the visibility that which IT resource are using which IT resource and what
kind of dependency they are having. What all total IT resources a company have, It also tells
about the availability of assets and also tells what action need to be performed in future so
that the business services will not get impacted.
ServiceNow CMDB is an ServiceNow ITSM application and one of most usable application
in most of the organization. There are lots of concepts in CMDB which we all want to
explore such as CI, CI Relationship, Service Mapping ServiceNow, Discovery etc. So lets
see what all will be discussed in this article.
In this article we will discuss about below points:
Let’s consider in an organization there are some application services such as organization
email system, organization Web application, Microsoft Exchange, Performance Monitoring
Application, Microsoft SharePoint, Service Proxy, Data storage, Networking, Information
Security, SAP application etc. and these application services are using some devices,
software applications, servers, hardware, licenses etc.
Now, the question is that what service mapping in CMDB will do in ServiceNow.
So, the answer is that service mapping in ServiceNow will discover all the Application
Services available in an organization for e.g. organization email system, organization
website, networking, data storage etc. and then through top-down mapping approach or
method. Service mapping in servicenow will build a comprehensive map of all the devices,
servers, network devices and configuration profile used in those application services. In other
words, we can say that Service Mapping in ServiceNow maps dependencies, based on a
connection between devices and applications.
This comprehensive map will show CI’s and the relationship in the application service. All
the application services which is discovered by service mapping cmdb will be stored
in (cmdb_ci_service_discovered) table.
We can use Service Mapping in cmdb only when discovery in ServiceNow is activated and
set up. To discover application services and devices, cmdb service mapping relies on
discovery and mid server. Service mapping uses the results discovered and uses MID Servers
to communicate with CIs in an organization. CMDB service mapping creates service maps
and creates a CI in the cmdb representing a business service.
If you are using your personal developer instance, you can type service mapping on the left
side filter navigator. Please find the below screenshot of the same:
Pattern are used to identify applications, properties of the application and connections to
other application. For e.g. there is a pattern of web applications which is used to find web
applications. CMDB service mapping uses patterns to discover and map ci's in cmdb.
Those applications which cannot be identify using pattern, service mapping discovery uses
traffic based discovery to identify those applications.
To perform traffic based discovery service mapping in servicenow uses traffic based
connection to collect network statistics. Traffic based discovery is used at initial stage and it
creates more inclusive map.
There are some questions which comes in mind when we talk about
discovery in cmdb, service mapping in cmdb are as mentioned below:
What I understand is that discovery focuses on Infrastructure and Service Mapping in cmdb
focuses on Business Services. If we elaborate it, then we can say that discovery discovers all
the infrastructure and application, but it does not relate anything to business services but on
the other hand service mapping in cmdb discovers only those applications and infrastructure
which directly supporting a business service and then map their relationships too, so it means
that Service Mapping in servicenow is more precise than of discovery.
Where the application services stored which is discovered by Service
Mapping in servicenow and for what ‘Service Maps’ are used?
Data coming from different sources can be of two types such as structured data or
unstructured data. Structured data which can be easily identified and unstructured data which
is unmanaged and difficult to identified. So, Data identification is a process which is used to
identify the data and also perform data analysis whereas Data reconciliation is a verification
process through which target data is compared with the source data.
Below is the syntax through which you can directly get the current year
Date should not greater than of 10 days from the current Date (ServiceNow Date Difference
Scenario):
Below is the code, which we have implemented on onChange() client script. Where user can
only select the dates in-between today and till the 10 days from today. Means user can select
date in the range between today to till 10 future days.
// Below code will return date in '2021-09-08' format (ServiceNow Date Format)
var startDate=g_form.getValue('u_start_date');
//Below is only for understanding and below code will return date in 'Wed Sep 08
2021 08:56:21 GMT+0530 (India Standard Time)-(Java script date format)' you can
uncomment same and see the result in alert box.
//Acutally we need javascript date in ServiceNow date format means like '2021-09-08'
so for that we have used below syntax
//Through this actually we are converting '2021-09-08' to 'Wed Sep 08 2021 08:56:21
GMT+0530 (India Standard Time)'
var stDate=new Date(startDate);
var curDate=new Date(currentDate);
var timeDifference=stDate.getTime()-curDate.getTime();
alert(timeDifference);
if(startDate<currentDate)
{
alert("You can only select date from today’s till 10 days from today");
g_form.setValue('u_start_date','');
}
Date should not smaller than of 5 days From Current Date (ServiceNow Date Difference
Scenario):
Let's assume the ServiceNow date requirement is where user can only give past date in the
field but the restriction is that he can only enter the date till last 5 days not smaller than that
and even he cannot enter the current date. Then you can use below code. You can modify the
code as per your requirement lets says for 90 days, 30 days etc. The only thing you have to do
is that you have to modify the conditions:
// Below syntax will return date in '2021-09-08' format (ServiceNow Date Format)
var startDate=g_form.getValue('u_start_date');
//Below is only for understanding and below code will return date in 'Wed Sep 08
2021 08:56:21 GMT+0530 (India Standard Time)-(Java script date format)' you can
uncomment same and see the result in alert box.
//Acutally we need javascript date in ServiceNow date format means like '2021-09-08'
so for that we have used below syntax
alert(startDate);
alert(currentDate);
//Through this actually we are converting '2021-09-08' to 'Wed Sep 08 2021 08:56:21
GMT+0530 (India Standard Time)'
var stDate=new Date(startDate);
var curDate=new Date(currentDate);
var timeDifference=stDate.getTime()-curDate.getTime();
alert(timeDifference);
if(startDate>currentDate)
{
alert("You have to enter past date till 5 days from today");
g_form.setValue('u_start_date','');
}
if((startDate<currentDate) && (dayDifference<(-5)))
{
alert("You have to enter past date till 5 days from today");
g_form.setValue('u_start_date','');
}
// If you want that user can enter current date in servicenow form than you can remove the
below if condition
if(dayDifference==0)
{
alert("You have to enter past date till 5 days from today");
g_form.setValue('u_start_date','');
}
End Date should not greater than start date in ServiceNow (ServiceNow Date Comparison):
Below is the code to compare the dates in servicenow. Date comparision is very simple.
Mostly the date comparison is done between two dates for e.g., User should not select date
greater than start date etc.
Below in onchange client script on field end date. means when user change the end date than
this code will run. you can change your field name in place of u_start_date and u_end_date as
per your requirement.
var startDate=g_form.getValue('u_start_date');
var endDate=g_form.getValue('u_end_date');
if(startDate>endDate)
{
alert("Please select date greater than of Start Date");
g_form.setValue('u_end_date','');
}
As you have already checked above code examples. Below are the very basic java script
functions we can use while working on ServiceNow dates requirements.
getDate(); //The getDate() method returns the day of the specific month (from 1 to
31)
getFullYear(); //getFullYear() method returns the year. for e.g., 2021.
getMonth(); // The getMonth() method returns the month (from 0 to 11). Means
January is 0 and December is 11
var currentDate=new Date(); //JavaScript uses the browser's time zone and display a
date as a full text string for e.g. '2021-09-08' to 'Wed Sep 08 2021 08:56:21 GMT+0530
(India Standard Time)'
var dupValArray=[1,3,5,7,9,5,7,5,10,24,54,5];
var arrayUtil= new ArrayUtil(); // ServiceNow Out of the Box API.
gs.info(arrayUtil.unique(dupValArray));
function findReqElementCount(value){
var occArray=[1,3,5,7,9,5,7,5,10,24,54,5];
var count=0;
for(var i=0;i<=occArray.length;i++){
if(occArray[i]==value){
count++;
}
}
gs.info(count);
}
What is GlideAggregate?
Using GlideAggregate instead of traditional methods such as looping through all records and
performing operations on each one has several advantages. Here are a few of them:
Performance: GlideAggregate performs much faster on large data sets than looping through
each record because it only retrieves the data required for the query.
Reduced memory usage: GlideAggregate uses less memory than traditional methods
because it retrieves only the required data for the query.
To use GlideAggregate, you need to create a new instance of the class and specify the table
and fields you want to query. You can then apply grouping and aggregate functions to the
data. Here is an example of a GlideAggregate query that retrieves the number of incidents
created per day in the last week:
In this example, we create a new instance of GlideAggregate for the incident table, add the
COUNT aggregate function to the sys_created_on field, group the data by the sys_created_on
field, add a query to retrieve only the last 7 days of data, and then execute the query. Finally,
we loop through the results using the next() method and retrieve the aggregate value and the
sys_created_on field value for each group.
GlideAggregate Aggregation Examples:
The GlideAggregate class provides several aggregate functions that you can use to calculate
values like COUNT, SUM, AVG, MAX, and MIN. In this blog post, we will explore each of
these functions and how they can be used in your ServiceNow instance.
COUNT
The COUNT function returns the number of records in the group. For example, if you want to
know how many incidents were created in the last week, you can use the COUNT function to
count the number of incidents that were created. Execute the below script in background
script and check the output.
SUM
The SUM function returns the sum of the values in the group. For example, if you want to
know the total amount of time spent on incidents in the last week, you can use the SUM
function to add up the time spent for each incident. Execute the below script in background
script and check the output.
The AVG function returns the average value of the group. For example, if you want to know
the average resolution time for incidents in the last month, you can use the AVG function to
calculate the average resolution time. Execute the below script in background script and
check the output.
MAX
The MAX function returns the maximum value in the group. For example, if you want to
know the highest priority of incidents in the last week, you can use the MAX function to find
the incident with the highest priority. Execute it in background script and check the output.
MIN
The MIN function returns the minimum value in the group. For example, if you want to know
the lowest priority of incidents in the last week, you can use the MIN function to find the
incident with the lowest priority. Execute the below script in background script and check the
output
var count=new GlideAggregate('cmdb_ci');
count.addQuery('cost','!=','0');
count.addEncodedQuery('manufacturer=b7e9e843c0a80169009a5a485bb2a2b5');
count.addAggregate('MIN','cost');
count.setGroup(false);
count.query();
while(count.next()){
gs.info(count.getAggregate('MIN','cost'));
}
GROUP_CONCAT
GROUP_CONCAT will concatenates all non-null values of the group in ascending order and
joins them with a comma (',') and returns the result as a String. Below is the example of the
GROUP_CONCAT_DISTINCT
ascending order, removes all the duplicates and joins them with a comma (',') and returns the
result as a String. Below is the example of the same execute it in background script and check
the output.
STDDEV
STDDEV populates standard deviation. Execute the below script in background script and
check the output. Currently, I am not sure about the use case scenarios for the same but soon I
The GlideAggregate class provides several aggregate functions that you can use to perform
calculations on a set of records. By using these functions, you can calculate values like
counts, sums, averages, maximums, and minimums. Whether you are a developer or an
administrator, understanding the capabilities of GlideAggregate functions can help you make
the most of your ServiceNow instance.
The GlideAggregate class in ServiceNow provides several functions that can be used to
perform aggregate calculations on a set of records. These functions can be used to calculate
values like COUNT, SUM, AVG, MAX, and MIN. In this blog post, we will explore each of
these functions in detail and provide examples of how to use them in your ServiceNow
instance.
addQuery()
The addQuery() function is used to add conditions to the GlideAggregate query. It takes two
or three parameters (when we use operators).The field to be queried
The operator for the query (e.g., '=', '>', '<', '>=', '<=', '!=', 'IN', 'NOT IN', etc.)
The value to be compared against
Example: Execute it in background script and check the output.
addAggregate()
addEncodedQuery()
query()
The query() function is used to execute the GlideAggregate query. Once executed, the
resulting records can be iterated over using the next() function.
Example: Execute it in background script and check the output.
next()
The next() function is used to iterate over the resulting records of the GlideAggregate query.
It returns true if there are more records to be processed.
Example: Execute it in background script and check the output.
getAggregate()
The getAggregate() function is used to retrieve the value of an aggregate function for the
current record. It takes one or two parameters. The aggregate function to retrieve (e.g.,
COUNT, SUM, AVG, MAX, MIN, etc.)
Example: Execute it in background script and check the output.
setGroup(false)
Useful function to set the groupby to false. Below is the example to use the same. Execute it
in background script and check the output.
var count=new GlideAggregate('cmdb_ci');
count.addEncodedQuery('manufacturer=b7e9e843c0a80169009a5a485bb2a2b5');
count.addAggregate('SUM','cost');
count.setGroup(false);
count.query();
while(count.next()){
gs.info(count.getAggregate('SUM','cost'));
}