1) What is Service Now?
Service now is a cloud based ITSM tool. Which is used to automate your business process
and provides a best service to customer all aspects of IT Services can potentially live in the
Service Now ecosystem of modules, This allows for broad control of how to best allocate
resources and design the process flow of those services.
2) Base or parent tables -- Child tables
1. Task table (task) 2. Configuration item (cmdb_ci) Incident, Problem, Change
Computer (ci_computer),
Server (ci_server)
3. Users (sys_user)
4. Groups (sys_user_group)
3) Types of change
Normal change
Its normal change generally when developer want to make some changes, need CAB
approval
Standard Change (Frequently)
Not required any CAB approval before make a change, its pre-approved cause of
frequently doing the same kind of change
Emergency Change
When customer raise emergency request then respective developer needs to be
implementing the changes immediately (with CAB Approval)
3) Tell me your experience with Service-Now?
Earlier my client was using BMC remedy tool; then they have decided migrate to Service-
Now, so they have given training me on Service-Now. Initially my career was starts with
just administration part but later I got a chance to working with other areas like in
development and implementation develop scoped application finally integration part
as well.
5). Could you please tell me what all you have done in Service-Now?
I am involved in all kind of activities from basic administration to advanced scripting and
customization. I have contributed my work in Incident, Problem, Change, SRM, Service
Catalog and Asset and Configuration Management, Knowledge management, Discovery,
Performance analytics areas. Recently I have started working on service Portal.
6) What is Incident?
Something is broken into your application or un expected interruption in your business
application is called incident
7) What is Problem?
When incidents are occurring similar kind of issues from multiple peoples or same category
we can consider as problem ticket.
Based on ticket trend analysis we can able to create problem ticket Then we can correct order
for that so we can find root cause analysis need to be fixed the issue permanently.
8. Tell me about your work in incident management?
I have implemented lots of the changes of the forms using for layout and form design,
created different kind of fields like reference field, choice field, string field, Data and
Time, Calculated fields. Also I have worked on server side scripting like business rules and
client side scripts like client scripts and applied UI policy, Data Policy, applying ACL rules
to restrict users.
I have also designed the email templates for email notifications, and also triggering notifications when the conditions are matched.
the
9) What do know about problem management in service-now?
Repetitive incidents will be logged as a problem ticket; technically I have done the same
stuff which I have done for the incident management like business rules, client scripts, ui
actions, ui policies, notifications.
10. Please share your experience on change management?
I have modified the workflow of change management table so that it can move for cab
approvals as per the requirement, also I have created new workflows for emergency change
request.
11. What is a business rule?
Business rule is a server-side script that runs when a record is displayed, inserted, deleted,
or when a table is queried. Use business rules to automatically change values in form fields
when the specified conditions are met.
Business rule are excuting from server side scripting that executes whenever a record is
inserted, updated, deleted, displayed or queried. The key thing to keep in mind while
creating a business rule is that when and on what action it has to execute. We have different
operation like
12. Types of business rules?
Before
After the user submits the form but before going to perform any action is taken on the
record in the database
After
After the user submits the form and ofter any action is taken on the record in the database
Async
When the scheduler runs the scheduled job is created from the business rule. The system
creates a scheduled job from the business rule after user submits the forms and after any
action is taken on the record in the database
Display Business Rule
Before the form is presented to the user, just after the data is read from the database
13) When business rules run?
Business rules run based on two sets of criteria:
The time that the business rule is configured to run relative to a record being modified or
accessed.
The database operation that the system takes on the record.
14) What is display business rule?
Display business-rules:
Display business rules are processed when a user requests a record form.
The data is read from the database, display rules are executed, and the form is presented to
the user.
1. 2. 3. 4. 5. 6. The current object is available and represents the record retrieved from the database.
Any field changes are temporary since they are not yet submitted to the database. To
the client,
The form values appear to be the values from the database; there is no indication that
the values were modified from a display rule. This is a similar concept to calculated
fields.
The primary objective of display rules is to use a shared scratchpad
object, g_scratchpad, which is also sent to the client as part of the form.
This can be useful when you need to build client scripts that require server data that
is not typically part of the record being displayed.
In most cases, this would require a client script making a call back to the server.
To populate the form scratchpad with data from a display rule:
// From display business rule
g_scratchpad.someName = "someValue";
g_scratchpad.anotherName = "anotherValue";
// If you want the client to have access to record fields not being displayed on the form
g_scratchpad.created_by = current.sys_created_by;
// These are simple examples, in most cases you'll probably perform some other
// queries to test or get data
To access the form scratchpad data from a client script:
// From client script
if(g_scratchpad.someName == "someValue") {
//do something special
}
15) Abort a database action in a before business-rule?
In a before business rule script, you can cancel or abort the current database action.
In a before business-rule script, you can cancel or abort the current database action using the
current.setAbortAction = true method. For example, if the before business rule is
executed during an insert action, and you have a condition in the script that
calls current.setAbortAction(true), the new record stored in current is not created in the
database.
16) How to lock user accounts using by business rule script?
We can lock user accounts if the user is not active.
The following business rule script locks user accounts if the user is not active in the LDAP
directory or the user does not have Self-service, ITIL, or Admin access to the instance.
Script
// Lock accounts if bcNetIDStatus != active in LDAP and user does not
// have self-service, itil or admin role
var rls = current.accumulated_roles.toString();
if(current.u_bcnetidstatus == 'active' && (rls.indexOf(',itil,') > 0 ||
rls.indexOf(',admin,') > 0 ||
rls.indexOf(',ess,') > 0 )) {
current.locked_out = false; }
else {
current.locked_out = true; }
var gr = new GlideRecord("sys_user");
gr.query();
while(gr.next()) {
gr.update();
gs.print("updating " + gr.getDisplayValue());
}
17) Before query business rules example?
We can use a query business rule that will be executes before a database query is made.
Use this query business rule to prevent users from accessing certain records. Consider the
following example from a default business rule that limits access to incident records.
Name : incident query
Table : Incident
When : before, query
Script
if(!gs.hasRole("itil") && gs.isInteractive()) {
var u = gs.getUserID();
var qc =
current.addQuery("caller_id",u).addOrCondition("opened_by",u).addOrCondition("watch_li
st","CONTAINS",u);
gs.print("query restricted to user: " + u); }
18) This sample business rule restricts the writing of the name field in the
sys_dictionary file when the entry exists:
// the element name cannot be written unless this is a new record (not yet in database)
function sys_dictionary_nameCanWrite() {
if (current.isNewRecord())
return;
else {
return false;
}
}
19) Difference between Business rule and script include?
A. Business Rule is something you want to run when anything will happen before/after
database update/insert for that record, definitely there are other options as well (like
display and query business rule) etc.
B. Script Include is like re-usable function, in simple example if you want to calculate the
date different between two date fields from incident form or change form then you can
have 1 script include and can have a Glide Ajax to call from client scripting to re-use
them for both the places.
20) How to converting global business rules to script includes
Global business rules are from earlier versions of Service Now,
Before Script Includes. Developers are now supposed to use Script Includes instead of
global business rules. Why is this?
Performance
Global business rules are evaluated for every server interaction. Every insert, update,
delete, or query of a record. They are “global”. Script Includes are different. They are
loaded on-demand and cached.
How to switch to Script Includes
If you have a number of global business rules you created on a previous version of Service
Now, you can switch them to Script Includes.
Here is an example GBR I used in for GRC report that found all Controls not linked to
Authoritative Source Content. The report isn‟t that important here, just how to convert that
GBR to a Script Include.
New Script Includes
You‟re new Script Include. Just copy the GBR script you are using into the Script Include.
You can convert to a more object-oriented format if you want, but that is a bonus with
accompanied risk of a coding mistake. The most efficient solution is just to copy the script.
21) How to deactivate Global Business Rule
Your Existing GBR. Either delete or deactivate. I choose to delete so that my past mistakes
are gone forever.
Business Rule
Name: getControlsNotLinkedtoASC
Table: Global [global]
Active: false
Script:
getControlsNotLinkedtoASC();
function getControlsNotLinkedtoASC() {
var controlList = new Array();
var grControl = new GlideRecord('grc_control');
grControl.query();
while (grControl.next()) {
var grControlAuthSource = new GlideRecord('m2m_control_auth_src_content');
grControlAuthSource.addQuery('control_name', grControl.sys_id);
grControlAuthSource.query();
if (!grControlAuthSource.hasNext()) {
controlList.push(grControl.control_id.toString());
}
}
return controlList;
}
22) What is a client script?
Client Script which runs on browser side or client side. This can be triggered on load, on
change, on submit, on cell edit.
OnLoad(): will run while loading a page,
OnChange(): will run while changing the cursor from the specified field,
On Submit(): when a form is submitted. This type allows you to cancel the submission, if
necessary.
OnCellEdit(): Runs when a cell on a list changes value.
Examples
onLoad() Scripts
An onLoad() script can runs when a form is first drawn and before control is given to the
user to begin typing. Typically, you use an onLoad() script to perform some client side
manipulation of the document on screen.
An onLoad() script must contain a function named onLoad(). Otherwise, it is entirely up to
you what your script does after it gets to the client.
For example, here is a trivial onLoad() script that displays a message box that says "Loading
..." while the page loads.
function onLoad() { alert ('Loading ...'); }
onSubmit() Scripts
An onSubmit() script runs when a form is submitted. Typically, you use
an onSubmit() script to validate things on the form and ensure that the submission makes
sense. As such,
onSubmit() scripts can potentially cancel a submission by returning false.
An onSubmit() script must contain a function named onSubmit().
For example, here is an onSubmit() script that prompts the user to confirm that a priority
one ticket should really be submitted. If the user clicks Cancel in the confirmation dialog
box, the submission is canceled.
Example
function onSubmit()
{
var priority = g_form.getValue('priority');
if (priority && priority == 1)
return confirm('Are you sure you want to submit a priority one ticket? The CIO will be
notified!');
}
onChange() Scripts
A.Unlike onLoad() and onSubmit() scripts, onChange() scripts apply to a particular widget
on a form rather than to the form itself. They are fired when a particular value changes on-
screen.
An onChange() script must contain a function named onChange().
All onChange() scripts are called with several parameters:
Example
For example, here is an onChange() script that notifies the user whenever the short
description field on a form changes.
function onChange (control , oldValue , newValue , isLoading ) {
alert('you changed short description from ' + oldValue + ' to ' + newValue); }
To prevent an onChange() script from running when the form loads, add the following to the
top of the script.
if(isLoading) { return; }
onCellEdit() Scripts
Scripts can be defined as onCellEdit() to run on the client side when the list editor interacts
with a cell.
Note: onCellEdit() scripts do not apply to list widgets on homepages or dashboards.
An onCellEdit() script must contain a function named onCellEdit().
An onCellEdit() script takes the following parameters:
Example:
function onCellEdit(sysIDs, table, oldValues, newValue, callback)
{
var hasDifferentValues = false;
for(var i = 0; i < oldValues.length; i++)
{
var oldValue = oldValues [i];
if (oldValue != newValue)
{
hasDifferentValues = true;
break;
}
}
var success = hasDifferentValues && performSomeFurtherValidation(sysIDs, table,
oldValues, newValue);
callback(success);
23) What are the variable supporting to client scripts?
The following API is supported via g_form:
g_form.setDisplay(name, display)
g_form.setVisible(name, visibility)
g_form.setMandatory(name, mandatory)
g_form.setValue(name, value, display_value)
g_form.getValue(name)
g_form.setReadOnly(fieldName, boolean)
24) How do I call a business rule from a client script?
To call a business rule from a client script, use GlideAjax
25) How to call business rule from client script through coding?
The Glide Ajax class enables a client script to call server-side code in a script include.
To use GlideAjax in a client script, follow these general steps.
Create a GlideAjax instance by calling the GlideAjax constructor. As the argument to the
constructor, specify the name of the script include class that contains the method you want
to call.
Call the addParam method with the sysparm_name parameter and the name of the script-
include method you want to call.
(Optional) Call the addParam method one or more times to provide the script-include code
with other parameters it needs.
26) How can we execute server side code in client script?
Execute the server-side code by calling getXML ().
27) What is difference between getXML and getXMLWait?
getXML()
It is the preferred method for executing the code, because it is asynchronous and does not
hold up the execution of other client code. Another method,
getXMLWait(),
It is also available but is not recommended. Using getXMLWait () ensures the order of
execution, but can cause the application to seem unresponsive, significantly degrading the
user experience of any application that uses it. getXMLWait () is not available to scoped
applications.
28) Call glide Ajax into Client script with Example
var ga = new GlideAjax('HelloWorld'); // HelloWorld is the script include class
ga.addParam('sysparm_name','helloWorld'); // helloWorld is the script include method
ga.addParam('sysparm_user_name',"Bob"); // Set parameter sysparm_user_name to 'Bob'
ga.getXML(HelloWorldParse); /* Call HelloWorld.helloWorld() with the parameter
sysparm_user_name set to 'Bob'
and use the callback function HelloWorldParse() to return the result when ready */
// the callback function for returning the result from the server-side code
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
29) Catalog Client Script Examples and Scenarios
Example: 1
Get the value of a variable
Use the following syntax to obtain the value of a catalog variable. Note that the variable
must have a name. Replace variable_name with the name of the variable.
g_form.getValue('variable_name');
Example: 2
Restrict the number of characters a user can type in a variable
This is an example of a script that runs when the variable is displayed, rather than when the
item is ordered.
functiononLoad()
{var sd = g_form.getControl('short_description');
sd.maxLength=80;
}
Example: 3
Color Code Approval Buttons
I use this one often. Color code the approval buttons so that they are easier to notice.It is
tempting to use this for many color changes in Service Now. How use Field Styles instead
as much as possible.
Client Script: Approval Button Color
When: onLoad
Script:
function onLoad() {
var approveButton = document.getElementById('approve');
var rejectButton = document.getElementById('reject');
if (approveButton) {
approveButton.style.background='green';
approveButton.style.color='white';
}
if (rejectButton) {
rejectButton.style.background='red';
rejectButton.style.color='white';
}
}
Example: 4
Pop an alert to the screen if a value is true
Client Script: Awesome Check
Type: onChange
Field: u_awesome_check
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'mike_awesome') {
alert('Yes this is true');
Example: 5
CALLBACK FUNCTION
Callback functions are make JavaScript far more flexible than it would be otherwise.
Typical functions work by taking arguments as input and returning a result. Functions take
an input and return an output.
JavaScript callback functions are different. Instead of waiting for a function to return that
result, you can use a callback to do this asynchronously. This not only helps with
performance, it strongly encouraged to use callback functions and asynchronous
programming.
Client Script: Set VIP
When: onChange
Field: caller_id
function onChange(control, oldValue, newValue, isLoading) {
var caller = g_form.getReference('caller_id');
if (caller.vip == 'true')
alert('Caller is a VIP!');
}
Example: 6 with a callback (recommended)
Client Script: Set VIP
When: onChange
Field: caller_id
function onChange(control, oldValue, newValue, isLoading) {
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function
}
function doAlert(caller) { //reference is passed into callback as first arguments
if (caller.vip == 'true')
alert('Caller is a VIP!');
}
Example: 7 with a callback (recommended)
Client Script: Set VIP
When: onChange
Field: caller_id
function onChange(control, oldValue, newValue, isLoading) {
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function
}
function doAlert(caller) { //reference is passed into callback as first arguments
if (caller.vip == 'true')
alert('Caller is a VIP!');
}
Example 8: remove option from choice list
This is an easy client script. Remove a value from a choice list if something is set.
Client Script: Category Inquiry Remove Impact 1
When: onChange
Field: Category
Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'inquiry') {
g_form.removeOption('impact', '1');
}
}
Comments
Post a Comment