ServiceNow Tips and Tricks
Filter out with condition "DOES NOT START WITH"
gr.addQuery('name',
'NOT LIKE', 'buddy%');
To Copy work notes from incident/task to any other task.
Copy the latest
work notes entry - work_notes.getJournalEntry(1)
To get all the work
notes entries in order with timestamp - work_notes.getJournalEntry(-1)
Cancel Our transaction in ServiceNow
ServiceNow Url/
cancel_my_transaction.do
Eg.
https://InstanceName.service-now.com/cancel_my_transaction.do
Add a warning message
g_form.addWarningMessage('TEST');
Terminate a user session (JUST FOR FUN)
GlideSessions.lockOutSessionsInAllNodes('USER_NAME')
Bookmark your PDI in such a way that you never need to enter username and
password
https://<instancename>.service-now.com/login.do?
user_name=admin&sys_action=sysverb_login&user_password=PutYourPasswordHere
Remove users from To field in ServiceNow notification (Global change)
Set the system property "glide.email.smtp.max_recipients" to "1" and for each recipient an individual email will be created
To track background processes in ServiceNow
‘sys_execution_tracker'
table (Execution Tracker) can be very useful to inspect details like
source record, Percent Completion, Start/Completion time with
real time execution details.
sys_progress_worker
table (Progress Worker) is also a good option and is visible to users from
left navigation menu under System Diagnostics unlike Execution
Tracker is not and needs to be manually navigated to.
SNC.CMDBUtil() is documented class with many functions to interact with CMDB. One function that does not seem to documented is 'isCMDB()'. You can pass tablename to the function and determine if the table is cmdb_ci or an cmdb_ci extended table. So you can quickly check if a table is cmdb_ci extended in a single line.
gs.info(new
SNC.CMDBUtil().isCMDB('cmdb_ci_hyper_v_rpool_comp')); //returns true
Note: Function does not work for CMDB (Base Configuration item) table.
gs.info(new
SNC.CMDBUtil().isCMDB('cmdb')); //returns false
To leverage the Java API to find the current time of different cities across the world.
var
SimpleDateFormat = Packages.java.text.SimpleDateFormat;
var TimeZone =
Packages.java.util.TimeZone;
var now = new
Date();
var
simpleDateFormat = new SimpleDateFormat('EEEE dd-MMM-yy HH:mm:ssZ');
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('UTC'));
gs.print('UTC =>
' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Europe/London'));
gs.print('Europe/London
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('America/New_York'));
gs.print('America/New_York
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('America/Los_Angeles'));
gs.print('America/Los_Angeles
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Europe/Zurich'));
gs.print('Europe/Zurich
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Asia/Calcutta'));
gs.print('Asia/Calcutta
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Europe/Copenhagen'));
gs.print('Europe/Copenhagen
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Asia/Tokyo'));
gs.print('Asia/Tokyo
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Singapore'));
gs.print('Singapore
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Australia/Sydney'));
gs.print('Australia/Sydney
=> ' + simpleDateFormat.format(now));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone('Pacific/Auckland'));
gs.print('Pacific/Auckland
=> ' + simpleDateFormat.format(now));
OUTPUT
*** Script: UTC
=> Sunday 03-Jul-22 02:03:34+0000
*** Script:
Europe/London => Sunday 03-Jul-22 03:03:34+0100
*** Script:
America/New_York => Saturday 02-Jul-22 22:03:34-0400
*** Script:
America/Los_Angeles => Saturday 02-Jul-22 19:03:34-0700
*** Script:
Europe/Zurich => Sunday 03-Jul-22 04:03:34+0200
*** Script:
Asia/Calcutta => Sunday 03-Jul-22 07:33:34+0530
*** Script:
Europe/Copenhagen => Sunday 03-Jul-22 04:03:34+0200
*** Script:
Asia/Tokyo => Sunday 03-Jul-22 11:03:34+0900
*** Script:
Singapore => Sunday 03-Jul-22 10:03:34+0800
*** Script:
Australia/Sydney => Sunday 03-Jul-22 12:03:34+1000
*** Script:
Pacific/Auckland => Sunday 03-Jul-22 14:03:34+1200
Script to delete and clean a table quickly in the background:
𝘷𝘢𝘳 𝘵𝘢𝘣𝘭𝘦𝘋𝘦𝘭𝘦𝘵𝘪𝘰𝘯 = 𝘯𝘦𝘸 𝘛𝘢𝘣𝘭𝘦𝘜𝘵𝘪𝘭𝘴();
𝘵𝘢𝘣𝘭𝘦𝘋𝘦𝘭𝘦𝘵𝘪𝘰𝘯.𝘥𝘳𝘰𝘱𝘈𝘯𝘥𝘊𝘭𝘦𝘢𝘯('<𝘺𝘰𝘶𝘳 𝘵𝘢𝘣𝘭𝘦 𝘯𝘢𝘮𝘦 𝘩𝘦𝘳𝘦>');
Accessing the Impersonate Dialog Directly
If you are testing
with a user who only have an end-user role (Portal Access only) and want to
access the traditional UI16 interface (platform view) with logout/login.
Use- /impersonate_dialog.do, this will directly load the Impersonate Dialog
page.
Syntax-
https://<< Instance Name >>.service-now.com /impersonate_dialog.do
Flow Default Characteristic of 50 action
By default, flow cannot have more
than 50 actions. To change the default behaviour, increase the value of
the “sn_flow_designer.max_actions” system property.
Cache
Sometimes to make
something work (specially client script) we need to clear the cache. To clear
the cache you can use the following:
In background script
type gs.cacheFlush() and run it.
But it is not
recommended to do it in Production instance as it will cause performance
issues.
But if you want to
clear the cache in Production, what you can do is pass some parameter to
gs.cacheFlush()
e.g.
gs.cacheFlush('syscache_ui_policy') it will not have much impact on the
performance as it will target only the specific area.
Reduce loading time of a table in
list view with lots of data?
Whenever we tried to
load a table in the list which holds lots of records like System logs, cmdb or
Emails table in the list view in instances with lots of data they might end up
transactions time our you have to wait for a long time for data to load.
Although you have a
filter option, but you can only use it until the table loads not while it's
loading so now there is a cool tip below that you can use on day-to-day basis.
In the navigator, you have to type -
<<TABLE NAME>>.filter Syntax - incident.filter(to open in same window) or
incident.FILTER (to open in a new window)
Alternatively, if you want to add a filter in the URL itself you have to use below- Syntax- https://INSTANCE .service-now. com/TABLENAME_list. do?sysparm_filter_only=true
All you have to do now is to apply the correct filter to narrow down the records you need like based on date-time or sys_id.
Pass data from widget to other
application on a portal page e.g. virtual agent?
spContextManager API makes it easy.
Method: addContext (Initializes a key and adds widget data as the value)
addContext(String key, Object context)
Example:
function ($scope,
spContextManager) {
spContextManager.addContext('agent-chat',
{
'approval_count':
5
});
};
if key is already
defined use updateContextForKey method instead to update context.
Most used navigation filter to navigate
directly to the list, form, or configuration view of a table. -
Command |
Behaviour |
<table name>.list |
Opens the list view of the table in the same
window or tab. |
<table name>.LIST |
Opens the list view of the table in a new window
or tab. |
<table name>.form or <table name>.do |
Opens the form view of the table in the same
window or tab. |
<table name>.FORM |
Opens the form view of the table in a new window
or tab.
|
<table name>.config |
Opens the configuration view of the table in the
same window or tab. |
<table name>.CONFIG |
Opens the configuration view of the table in a
new window or tab
|
Exporting a CSV file from a ServiceNow
Exporting a CSV file
from a ServiceNow list is a well-known feature, and one way to do it is by:
1. Prepare the desired
List with your conditions
2. Click on the
hamburger icon in the one-column header
3. Go to Export ->
CSV
💫 But, there in another way to get a
CSV file from the desired list and that is just by adding the following string: &𝘾𝙎𝙑&𝙨𝙮𝙨𝙥𝙖𝙧𝙢_𝙙𝙚𝙛𝙖𝙪𝙡𝙩_𝙚𝙭𝙥𝙤𝙧𝙩_𝙛𝙞𝙚𝙡𝙙𝙨=𝙖𝙡𝙡
at the end of the URL.
This will directly
execute the CSV download task.
nice blog with very good information
ReplyDeleteServiceNow course Online
Best ServiceNow Online Training
ServiceNow developer Training Online
Thank you for introducing this tool. keep it updated.
ReplyDeleteServiceNow Online Training Hyderabad
ServiceNow Online Training India