Book Image

Mastering ServiceNow Scripting

By : Andrew Kindred
Book Image

Mastering ServiceNow Scripting

By: Andrew Kindred

Overview of this book

Industry giants like RedHat and NetApp have adopted ServiceNow for their operational needs, and it is evolving as the number one platform choice for IT Service management. ServiceNow provides their clients with an add-on when it comes to baseline instances, where scripting can be used to customize and improve the performance of instances. It also provides inbuilt JavaScript API for scripting and improving your JavaScript instance. This book will initially cover the basics of ServiceNow scripting and the appropriate time to script in a ServiceNow environment. Then, we dig deeper into client-side and server-side scripting using JavaScipt API. We will also cover advance concepts like on-demand functions, script actions, and best practices. Mastering ServiceNow Scripting acts as an end-to-end guide for writing, testing, and debugging scripts of ServiceNow. We cover update sets for moving customizations between ServiceNow instances, jelly scripts for making custom pages, and best practices for all types of script in ServiceNow. By the end of this book, you will have hands-on experience in scripting ServiceNow using inbuilt JavaScript API.
Table of Contents (18 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Preface

ServiceNow is gradually evolving as the platform of choice for IT Service management. Industry giants such as RedHat and NetApp have adopted ServiceNow for their operational needs. ServiceNow provides clients with an extra add-on when it comes to their baseline instances, as scripting can be used to customize and improve the performance of their instances. ServiceNow provides inbuilt JavaScript API for scripting and improving an instance using JavaScript.

This book will initially cover the basics of ServiceNow scripting and the appropriate time to script in a ServiceNow environment. Then, we will dig deeper into client-side and server-side scripting using JavaScipt API. We will also cover advanced concepts such as on-demand functions, script actions, and best practices. This book will act as an end-to-end guide to writing, testing, and debugging scripts in ServiceNow. We will also cover update sets for moving customizations between ServiceNow instances, Jelly scripts for making custom pages, and best practices for all types of script in ServiceNow.

At the end of this book, you will have hands-on experience of scripting in ServiceNow using the inbuilt JavaScript API.

Who this book is for

This book is targeted toward ServiceNow administrators or any stakeholder willing to learn inbuilt JavaScript APIs used to script and customize ServiceNow instances. Experience of working with ServiceNow is mandatory.

What this book covers

Chapter 1, Getting Started, introduces you to the basics of ServiceNow scripts. That is, when/why it is appropriate to develop custom functionality through scripting. It also introduces when to configure and customize.

Chapter 2, Exploring the ServiceNow Glide Class, provides you with the details of how ServiceNow has exposed its JavaScript APIs, which enables you to write your scripts conveniently. Using these exposed APIs, you can perform various database operations. You will explore some of the commonly used server-side glide classes and client-side glide classes.

Chapter 3, Introduction to Client-Side Sripting, helps you understand the client-side scripting of ServiceNow. You will learn about the concepts of client scripts and UI policies. You will see how to write and test basic client-side scripts. You will go through some practical examples of client-side scripting to have better understanding of the functionality.

Chapter 4, Advanced Client-Side Scripting, will help you understand the more advanced side of client-side scripting in ServiceNow. You will learn about AJAX calls and UI actions. You will go through some advanced practical examples of client-side scripting to get a better understanding of the functionality.

Chapter 5, Introduction to Server-Side Scripting, covers the details of server-side scripting in ServiceNow. It will help you understand the concepts of business rules, UI actions, and access controls in depth. You will also learn how to write and test a server-side script. You will go through some of the practical examples of server-side scripting to understand the functionality better.

Chapter 6, Advanced Server-Side Scripting, will cover the advanced side of server-side scripting in ServiceNow. It will help you understand the concepts of script includes, background scripts, workflow scripts, and scheduled jobs. You will go through some practical examples of advanced server-side scripting to understand script calls, the system scheduler, and queuing events in the system.

Chapter 7, Introduction to Custom Pages, introduces you to Jelly. This will provide an insight into how Jelly is used in ServiceNow. You will also learn how to create a UI page using JavaScript with Jelly scripting.

Chapter 8, Scripting with Jelly, further progresses knowledge of Jelly. This will provide further insight into how Jelly scripting is used in ServiceNow. You will also learn how to create UI Macros to enhance a UI page.

Chapter 9, Debugging the Script, introduces the mechanism of debugging your script in ServiceNow. You will explore the various tools and methods used in troubleshooting and debugging your code in ServiceNow.

Chapter 10Best Practices, covers various best practices developers should follow to use ServiceNow in an efficient manner. It also talks about logging and monitoring system performance to control your ServiceNow environment.

Chapter 11Deployments with the Update Sets, guides you on how to move your configurations and customizations from instance to instance. It also helps you understand how to use update sets while working on global and scoped applications. You will also learn how to avoid some common pitfalls while working with update sets.

Chapter 12Building a Custom Application Using ServiceNow Scripting, provides you with an end-to-end implementation of scripting in ServiceNow. You will learn how to build a custom application using scripting provided by ServiceNow.   

 

To get the most out of this book

Before starting with Mastering ServiceNow Scripting, it is advised that you have a good understanding of the ServiceNow platform. It is advisable to have a system administrator certification or similar knowledge, and to be aware of forms, lists, and tables in ServiceNow. You should also be able to comfortably navigate around a ServiceNow instance.

Some knowledge of JavaScript will be advantageous, but is not compulsory as the examples given will give you script to try and get started with.

It is advised to have a ServiceNow instance that you can use to try out the examples and create some scripts of your own. If you do not have an instance at this point, personal developer instances (PDI's) can be requested from ServiceNow for users who would like to improve their ServiceNow skills.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-ServiceNow-Scripting. In case, there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/MasteringServiceNowScripting_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The onLoad client script type runs script when a form is loaded."

A block of code is set as follows:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Type appropriate comment here, and begin script below

}

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "To access the studio navigate to System Applications | Studio"

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

Disclaimer

The code supplied in this book is for use in development scenarios to further knowledge of ServiceNow scripting. Use of the code provided in this book is at the readers own discretion. The author and publisher are not responsible and do not accept liability for any damages or negative impacts brought about from any code used from this book.