ServiceNow Interview Questions and Answers – User Shared Q&A (Set 6)

Sammy 2023-07-27 09:42:42
How to update change state from "Scheduled" to "Implement" automatically when Planned start date is reached?

Suresh Thorati 2023-09-26 07:14:18
1. Create a BR on Change Table. a. State = Scheduled Advanced: use glide time
0 Helpfuls
Trupti 2023-10-09 11:15:32
- You can either use Flow Designer or Scheduled Job. - Schedule it to execute daily. - Glide into 'Change' table and check if planned start date = todays date and state=scheduled then update change state to 'implement'
0 Helpfuls
snowexpertaastik 2024-11-02 04:36:14
Basically you can write one Scheduled job that runs daily and check those whose Planned Start date is today and if records matches conditions then update the state of those records to implement . Below is the sample code var changeReqs = new GlideRecord('change_request'); changeReqs.addEncodedQuery('start_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'); changeReqs.query(); while(changeReqs.next()){ changeReqs.setValue('state',-1); changeReqs.update(); }
0 Helpfuls
0 Helpfuls


Satyapriya Biswal 2023-08-05 04:58:56
I was asked that write a background script that will show how many roles the current logged in user have. Can anyone help me to answer this question.

Aastha 2023-08-06 13:11:44
var gr = new GlideRecord('sys_user_has_role'); gr.addQuery('user','6816f79cc0a8016401c5a33be04be441') gr.query(); gs.print(gr.getRowCount()); while(gr.next()) { //one way to do it }
0 Helpfuls
ps 2023-08-07 08:56:19
var userid = gs.getUserID(); var gr = new GlideRecord('sys_user_has_role'); gr.addQuery('user.sys_id', userid); gr.query(); while(gr.next()){ gs.print(gr.role.getDisplayValue()); gs.print(gr.getRowCount()); }
0 Helpfuls
Ria 2023-08-23 11:15:54
Whenever we have to find out count of something then it is recommended to use GlideAggregate API, using GlideRecord API with getRowCount method is not efficient and it is not considered as best practice. Therefore you can rather use below code. var userid = gs.getUserID(); var gaRoleCount=new GlideAggregate("sys_user_has_role"); gaRoleCount.addQuery("user",userid); gaRoleCount.addAggregate("COUNT","role"); gaRoleCount.query(); if(gaRoleCount.next()){ gs.print("Role Count for logged in user:" gaRoleCount.getAggregate("COUNT","role"); }
1 Helpfuls
Satyapriya Biswal 2023-08-25 02:11:26
Thanks
0 Helpfuls
Praveen K 2023-09-20 23:43:56
Hi Ria, In 4th line you are grouping the count by role which is incorrect it should be only gaRoleCount.addAggregate("COUNT"); Check below code for more info var userid = gs.getUserID(); var gaRoleCount=new GlideAggregate("sys_user_has_role"); gaRoleCount.addQuery("user",userid); gaRoleCount.addAggregate("COUNT"); gaRoleCount.query(); if(gaRoleCount.next()){ //gs.print(gs.getUserName()) //gs.print(userid) gs.print("Role Count for logged in user:" gaRoleCount.getAggregate("COUNT")); }
1 Helpfuls
Bharath 2024-07-12 13:27:33
gs.print("Role Count for logged in user:" gaRoleCount.getAggregate("COUNT")) in this line was error in background script, Please once check it Tank You..
0 Helpfuls
anonymous 2026-02-23 04:38:52
var a=gs.getUser().getRoles(); gs.log(a); gs.log(a.size());
0 Helpfuls
0 Helpfuls


Ranjit 2023-08-07 20:05:22
Whether the g_scarthpad can be used on all the types of client script?

Naveen 2023-08-19 01:03:09
g_scratchpad is used only in Onload Client scripts to get the data from Display business rule.
1 Helpfuls
Roshan 2023-08-24 08:05:47
In most of the use cases, we access it in onLoad client script. However g_scratchpad object can be accessed in all type of client scripts. In fact it can be accessed in UI policy script also. Here is very important use case where it can be used in on submit client script, if we want to validate something on submit of the form but data is not available on client side. Normally we use GlideAjax to get server side data but GlideAjax fails in onSubmit client script (GlideAjax is asynchronous call therefore form gets submitted before GlideAjax returns result). Therefore we can store result in g_scratchpad object in onChange client script and based on value we can restrict form submission in on submit client script.
0 Helpfuls
0 Helpfuls


Mujahid 2023-08-10 19:21:28
4. If you used GlideAjax method to get server side data then why used GlideAjax, why not getReference or Display BR?

Saritha 2023-08-29 12:48:11
g_scratchpad is sent once when a form is loaded (information is pushed from the server to the client), whereas GlideAjax is dynamically triggered when the client requests information from the server. If you're using getReference you will get ALL data for each record you "get" whether you need it or not.
0 Helpfuls
0 Helpfuls


Priyanka 2023-08-11 02:43:57
What is affected CI?

Kishan 2023-08-26 13:04:39
Affected CI's are the CI's which are affected by associated change. This CI's are later considered to populate Impacted CI's or services. More Details Here : https://docs.servicenow.com/en-US/bundle/sandiego-it-service-management/page/product/change-management/concept/c_AffectedCIsAndImpactedServices.html
0 Helpfuls
0 Helpfuls


Samarth Chadda 2023-08-21 04:02:58
How to encrypt and decrypt a attachment record which is being attached on Incident record?

Nikhil Kamlekar 2024-04-20 12:23:45
You can find the "Column Level Encryption." course in Now Learning. To encrypt the attachment or particular field.
0 Helpfuls
0 Helpfuls


VINAY 2023-08-22 07:21:37
What is MVRS(multi Row variable set) and explain interview point of view.

Satyapriya Biswal 2023-09-22 17:47:54
Multirow Variable set is used to capture variable data in a grid layout while submitting a catalog item request for a group of entities. It is very useful when you want to create multiple order in one request.
0 Helpfuls
0 Helpfuls


Balaji 2023-08-25 02:19:29
When we will use client script and script include with glide Ajax.Please can you explane with one use case

Atul 2023-09-26 11:37:56
Whenever you need data in client script which is not available on the form then you will need to get it from server database. And to do so we can use GlideAjax. OR if you need to perform any operation/validation which requires server side script then we need to use GlideAjax.
0 Helpfuls
0 Helpfuls


Saidulu Yadav 2023-08-25 07:27:22
what is main difference between UI Policy and Client Scripts.

William 2023-10-06 11:26:00
- We can execute client script on submit or on cell edit (list field update) but we cannot execute UI policy on submit or on cell edit. - We can execute client script for specific view but we cannot do the same via UI Policy. - UI Policies are faster as compare to Client scripts, therefore ServiceNow recommends to use UI Policies wherever possible.
0 Helpfuls
Arpan 2023-10-16 18:59:04
UI Policies can be run for a specific view if you uncheck the Global field and then enter the view name you need.
1 Helpfuls
Surendra 2023-10-23 22:44:55
Hi William We can execute client script or UI policy for the specific view as well.
0 Helpfuls
2 Helpfuls


Satyapriya Biswal 2023-08-31 08:06:58
What is the use of stop processing check box in inbound email action?

Siva 2024-02-05 10:29:15
All Inbound actions process according to the order value defined. When "Stop Processing" checkbox is set to true it will stop processing further inbound email actions.
0 Helpfuls
0 Helpfuls






Fuel My Passion

Loving the content? Well, of course you are. Here’s your chance to indirectly fuel the chaos that keeps this website running. Your contribution helps keep the wheels turning and allows me to continue pretending to be a responsible adult—while cranking out more content for you. Thanks for supporting my delusional dreams and helping me keep this website alive!


Buy Me a Coffee

Support with UPI

If you prefer making a UPI payment to support the website maintenance cost, scan the QR code below:

UPI QR Code

Comments