Learning ServiceNow
eBook - ePub

Learning ServiceNow

Tim Woodruff

Share book
  1. 356 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning ServiceNow

Tim Woodruff

Book details
Book preview
Table of contents
Citations

About This Book

IT Service management at your fingertipsAbout This Book• Leverage ServiceNow's capabilities to achieve improved service management and excellent results in your IT operations by following step-by-step, practical instructions• Build core administration, management, and maintenance skills with IT service management and IT operations management• Improve your workflow efficiency by designing and creating responsive and automated workflowsWho This Book Is ForThis book is for IT professionals and administrators who are planning to or are already trying to implement ServiceNow in their organization for Enterprise IT service management tasks.Some familiarity with web technologies (JavaScript) would be helpful. System administration experience is necessary.What You Will Learn• Acquire and configure your own free personal developer instance of ServiceNow• Read (and write!) clear, effective requirements for ServiceNow development• Avoid common pitfalls and missteps that could seriously impact future progress and upgradeability• Know how to troubleshoot when things go wrong using debugging tools• Discover developer "tips and tricks"• Pick up great tips from top ServiceNow development and administration professionals, and find out what they wish they knew when they were starting outIn DetailThis book shows you how to put important ServiceNow features to work in the real world. We will introduce key concepts and examples on managing and automating IT services, and help you build a solid foundation towards this new approach. We'll demonstrate how to effectively implement various system configurations within ServiceNow. We'll show you how to configure and administer your instance, and then move on to building strong user interfaces and creating powerful workflows.We also cover other key elements of ServiceNow, such as alerts and notifications, security, reporting, and custom development. You will learn how to improve your business' workflow, processes, and operational efficiency. By the end of this book, you will be able to successfully configure and manage ServiceNow within your organization.Style and approachThis book is a step-by-step practical tutorial to help you quickly deploy and configure ServiceNow in your organization.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning ServiceNow an online PDF/ePUB?
Yes, you can access Learning ServiceNow by Tim Woodruff in PDF and/or ePUB format, as well as other popular books in Informatik & Unternehmensanwendungen. We have over one million books available in our catalogue for you to explore.

Information

Year
2017
ISBN
9781785887536

The Server-side Glide API

In 2003, CEO Fred Luddy started a company called GlideSoft, which specialized in IT Service Management applications. Three years later, the company changed its name to ServiceNow, but the Glide name stuck for the API!
The Glide API is available on both the server and the client (though only a subset of the API is available on the client), and it consists largely of several classes about which we'll learn in this chapter; several of which are:
  • Server-side Glide classes:
    • GlideRecord
    • GlideAggregate
    • GlideElement
    • GlideDate and GlideDateTime
    • GlideSession
    • GlideSystem
  • Client-side Glide classes:
    • GlideRecord
    • GlideAjax
    • GlideForm
    • GlideList2
    • GlideMenu
    • GlideUser
Each class in the Glide API may consist of methods (executable functions within the class), and properties (variables stored within the class, which may be set on initialization of a new instance of the class).
This chapter largely consists of API documentation. We recommend that you read through it once, and then dog-ear this chapter so that you can come back to it for reference later on.

The structure of an API class

First, let's define a few terms. According to Mozilla's object-oriented JavaScript documentation, a class is sort of like a template for an object. It pre-defines the methods and properties of an object generated from the class.
An object therefore, is simply an instance of a class!
A method is a function or subroutine that's declared as part of a class (and any objects that are instances of that class).
A constructor is a special type of function that runs when an object is declared as a new instance of a class using the new keyword. In ServiceNow, this constructor function is usually called initialize. Any arguments passed into the class during instantiation will be passed into this function, which effectively builds the object that will be returned.
Naming convention dictates that while variable names use camelCase capitalization, class names use SentenceCase capitalization.
Here is a simple example of what a very simple class might look like:
 var MyClass = Class.create(); 
MyClass.prototype = {
initialize: function(initArg) {
this.localProperty = initArg;
},
getLocalProperty: function() {
return this.localProperty;
},
type: 'MyClass'
};
Now let's break this down line-by-line, and see how it works.
On line 1, we declare our class (MyClass) using a special ServiceNow API, Class.create(). As it happens, JavaScript doesn't technically have a data type called Class. Instead, it relies on function/object prototype extensions. In order to simplify this, and provide syntax more similar to the backend Java (and more similar to what most object-oriented programming languages use), ServiceNow provides Class.create() as a simple way to generate a basic class-esque object.
On line 2, we take this basic class scaffolding that we generated on line one, and extend that prototype by adding some stuff to it (everything between the curly braces: { and }).
On line 3, we declare the initialize method. This is a special method of our class, which is called automatically whenever a new object is generated (instantiated) from our class using the new keyword like so:
 var myObj = new MyClass('input'); 
Any arguments passed into this instantiation process (the string input in the preceding case), are passed into this initialize method.
Next, on line 4, we set a property in the scope of the instantiated object using the keyword this. In this case, any time we create an instance of this class, the property called localProperty will be initialized with the value that was passed into the constructor function.
On line 6, we declare another method called getLocalProperty. This is a method that can be called from objects created from our class, and which (on line 7) returns the value of the property that was set on initialization.
Finally, on line 9, we declare the type property of our class (and instantiated objects). This is just a string that you can access to determine what class child objects were created from.

Server-side APIs

Server-side APIs consist of classes and methods that are available to scripts executing on the server. When a script executes on the server, it is able to do so because of an open-source implementation of JavaScript, written in the Java programming language, called Mozilla Rhino. This allows us to interact with Java applications such as ServiceNow by scripting in JavaScript, despite the fact that the languages are not inherently cross-compatible.

GlideRecord

The GlideRecord class is one of the most ubiquitous and useful classes in ServiceNow. Its primary function is to query a database table, and present values corresponding to each record in that table, that matches a given query. It can also be used to add, modify, or delete records. A GlideRecord object consists of properties with names corresponding to each field in the table. In the client-side Glide API, these properties usually contain strings, whereas on the server-side API, these properties contain GlideElement JavaScript Objects with their own methods and properties.

Initialize

A GlideRecord object must first be initialized by using the new keyword (which calls the initialize() constructor method) and passing in a table name as a string. This tells the new GlideRecord object what table any subsequent queries or new records are created on.

Example usage

Initialize a new GlideRecord object on the Incident table, and store it in the gr variable:
 var gr = new GlideRecord('incident'); 

addQuery()

The addQuery() method of the GlideRecord class can be called in three different ways, depending on whether one, two, or three arguments are supplied to it. If one argument is passed into the addQuery() method, then it'll assume that the argument is an encoded query. Encoded queries are a single string that represents all of the conditions in a single query (or even multiple queries)!
There isn't any official documentation on how to construct an encoded query (though it isn't hard to figure out), but there is a very easy to build one yourself - simply navigate to the table you want to run the query on, and use the query builder! For example, here's a query on the incident table where the "assigned to" user is active, and either the Incident is active, or the state is set to new, in progress, or on hold:
You can build a filter on a given table using the query builder, and then apply that same filter to your GlideRecord query by simply right-clicking the last condition in the query breadcrumbs above the list view, and clicking on Copy query.
This is similar to the legacy addEncodedQuery() method:
You'll see an example of this single-argument usage in the following section. On the other hand, if you pass in two arguments, then it is assumed that the first argument is the field name, and the second argument is the expected value.
Finally, if you pass in three arguments to the addQuery() method, you may specify not only a field and value, but an operator between them. Operators that you can...

Table of contents