ServiceNow Cookbook Second Edition Manage and automate your workflow for efficient IT service management John Benedetti Ashish Rudra Srivastava BIRMINGHAM - MUMBAI ServiceNow Cookbook Second Edition Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Gebin George Acquisition Editor: Meeta Rajani Content Development Editor: Abhishek Jadhav Technical Editor: Prachi Sawant Copy Editors: Safis Editing, Dipti Mankame Project Coordinator: Judie Jose Proofreader: Safis Editing Indexer: Pratik Shirodkar Graphics: Tom Scaria Production Coordinator: Aparna Bhagat First published: February 2017 Second edition: January 2018 Production reference: 1250118 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78883-405-6 www.packtpub.com mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the authors John Benedetti is a senior technical consultant for organizations adopting and growing in ServiceNow. He holds ServiceNow, ITIL, AWS, and Microsoft certifications and is a Certified ScrumMaster. He holds a bachelor of science degree in Informatics and spends an irresponsible amount of time tinkering and making technology do interesting, though not necessarily useful things. When he's not working, he enjoys cooking and goes on new adventures with his wife Karla and indoctrinating his children Gabriel and Catelyn in The Ways of the Force, The Natural 20, and There's Always Next Year. Ashish Rudra Srivastava is an ITIL and ServiceNow Certified Professional who has assisted multiple global organizations in ITSM, CRM, BPM, and Infrastructure Management implementations and solutions delivery. He works as a ServiceNow consultant, developer, and trainer and has trained numerous industry professionals in ITSM tools, such as ServiceNow, BMC Remedy, and JIRA in administration, development, and implementation areas. He is a strategic partner to clients in insurance and banking domains. About the reviewer Rahul Maktedar is an ITSM and project management professional, currently working with ImaKumo, an ATOS company, in Singapore. He has 13+ years of experience in IT industry and has played many key roles in his career—most recently as a Global PM for SNow implementation in France, CH, UK, and India for an insurance giant. He is an IT engineer, an IIMC alumnus and earned 12+ IT Certs, including SNow CSA/CIS, PMP, ITIL Expert, ScrumMaster. He is living in Singapore since 9 years with his family. His hobbies are reading, travelling, flying drones, and he has visited 25 different countries till now. I must thank my wife Poonam, who has endured with my late-night work and book reviewing sessions; her patience and understanding have helped me to deliver on my commitments in time. Lots of love to my 5 years old superkid Varad, who refreshed me with his energetic activities, kiddy fights, and brilliant questions, especially in low times. What this book covers , Getting Started with ServiceNow, will focus on provisioning your own individual instance of ServiceNow and getting accustomed to the environment. Chapter 1 , Performing Core Configuration and Management Tasks, will help you learn how to perform core configuration and management activities. Chapter 2 , Building and Designing Data-Driven Apps, we will cover all of the aspects of application development within ServiceNow. Chapter 3 , Configuring Alerts and Notifications, will help you understand how communication and proactive notifications are essential to any IT Service Management application. Chapter 4 , Building and Configuring Reports, will help you understand how you can view and create reports, create a shared code base of reporting elements, automate reporting tasks, and create visualizations for reporting data. Chapter 5 , Creating and Configuring Workflow Activities, will deep dive into managing the life cycle of tasks. In this, we will demonstrate how to set the conditions for when a workflow is triggered and create an ad hoc notification. Chapter 6 , Auditing and Diagnosing ServiceNow, will look at several approaches to discover bugs or other unanticipated behavior through integrated logging, debugging, and auditing. Chapter 7 , Service Portal, begins by taking a look where portals are configured and then launching one of your own. Further, we'll walk Chapter 8 through refactoring and customizing your new portal. , Overview of Additional Modules and Kingston, offers a plethora of additional modules that can help customers continue to grow and improve their IT organization as well as others. Chapter 9 Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.pac ktpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface Who this book is for What this book covers To get the most out of this book Download the color images Conventions used Sections Getting ready How to do it… How it works… There's more… See also Get in touch Reviews 1. Getting Started with ServiceNow Introduction First steps with ServiceNow application Getting ready How to do it... Configuring LDAP authentication There's more... See also ServiceNow frontend navigation Getting ready How to do it... The Nav Bar The Service Portal ServiceNow backend navigation How to do it... Tables Records ACLs Workflow Editor REST API Explorer See also ServiceNow essential modules (ITIL) How to do it... Request Management Incident Management Change Management Problem Management Knowledge Management See also Managing your profile in ServiceNow How to do it... User profile Notifications Impersonation See also 2. Performing Core Configuration and Management Tasks Introduction Setting up your basic configuration Getting ready How to do it... See also Configuring ServiceNow forms Getting ready How to do it... There's more... See also Configuring UI policies on ServiceNow forms Getting ready How to do it... See also Configuring UI actions on forms Getting ready How to do it... See also Using ServiceNow plugins Getting ready How to do it... See also Understanding ServiceNow tables schema Getting ready How to do it... See also Getting into the CMDB Getting ready How to do it... There's more... See also Understanding the system dictionary Getting ready How to do it... See also Setting up an SLA or other contracts Getting ready How to do it... See also Setting up system rules Getting ready How to do it... See also Understanding deployments or update sets Getting ready How to do it... There's more... See also 3. Building and Designing Data-Driven Applications Introduction Starting a new application Getting ready How to do it... See also Adding new components to your application Getting ready How to do it... See also Publishing a new application Getting ready How to do it... There's more... See also Using the Team Development plugin Getting ready How to do it... See also Getting into client scripting Getting ready How to do it... There's more... See also Getting into server scripting Getting ready How to do it... There's more... See also Understanding development best practices – script includes Getting ready How to do it... There's more... See also Understanding web services Getting ready How to do it... There's more... See also Implementing automated testing Getting ready How to do it... There's more... See also 4. Configuring Alerts and Notifications Introduction Setting up email notifications for users Getting ready How to do it... See also Working with email templates Getting ready How to do it... See also Getting into notification scripts Getting ready How to do it... See also Understanding email watermarking Getting ready How to do it... See also Email troubleshooting Getting ready How to do it... See also Configuring delegates Getting ready How to do it... See also 5. Building and Configuring Reports Introduction How to view and run reports Getting ready How to do it... See also Creating custom reports Getting ready How to do it... See also Getting into reporting templates Getting ready How to do it... See also How to schedule a report Getting ready How to do it... See also Creating a dashboard Getting ready How to do it... See also Working with the database view for reporting Getting ready How to do it... See also 6. Creating and Configuring Workflow Activities Introduction Setting up workflow conditions Getting ready How to do it... See also Setting up approval activities Getting ready How to do it... See also Adding a task activity Getting ready How to do it... See also Adding notifications Getting ready How to do it... See also Subflows – triggering a workflow from another workflow Getting ready How to do it... See also Using timer activities Getting ready How to do it... See also How to use workflow utilities Getting ready How to do it... See also 7. Auditing and Diagnosing ServiceNow Introduction Understanding auditing in ServiceNow Getting ready How to do it... See also Working with auditing tables Getting ready How to do it... There's more... See also Understanding ServiceNow upgrades Getting ready How to do it... There's more... See also Working with system logs Getting ready How to do it... See also Session debugging Getting ready How to do it... See also Background scripts Getting ready How to do it... See also 8. Service Portal Introduction Configuring a portal Getting ready How to do it... See also Why mobile matters Getting ready How to do it... See also Branding and themes Getting ready How to do it... See also Portal pages Getting ready How to do it... See also Portal widgets Getting ready How to do it... See also Building a new widget Getting ready How to do it... There's more... See also 9. Overview of Additional Modules and Kingston Introduction Understanding Discovery Getting ready How to do it... See also Understanding Orchestration Getting ready How to do it... See also Service Mapping Getting ready How to do it... See also Cloud Management Getting ready How to do it... See also Governance, Risk, and Compliance Getting ready How to do it... See also Human Resources Getting ready How to do it... See also Edge Encryption Getting ready How to do it... See also Kingston – Flow Designer Getting ready How to do it... See also Kingston – Agent Intelligence How to do it... See also Other Books You May Enjoy Leave a review - let other readers know what you think Preface ServiceNow is the ideal platform for you to create enterprise-level applications, giving both requesters and fulfillers better visibility and access to a process. With this title, we'll guide you through the world of ServiceNow, letting you take on the best the platform offers you with the smallest amount of hassle. Starting with the core configuration and management tasks, this book will help you build data-driven apps, and it will also explore development best practices. You will learn to set up email notifications for users and work with the database view for reporting. Next, you will be building/designing data-driven apps where you will learn to implement the new Automated Testing Framework. You will also be guided through creating various tasks from the workflow and also how to make the most of the workflow utilities available in ServiceNow. Following this, you will learn about Service Portal, new with Helinski, where you will learn how to configure the portal, how to perform integrations with different cloud platforms, and tips and tricks on using the portal effectively. Finally, you will learn to use paid plugins such as Discovery, Orchestration, and Service Mapping. By the end of this book, you will acquire immediately applicable skills to address everyday problems encountered on the ServiceNow platform. Who this book is for If you are an IT professional or an administrator who has some experience of working with ServiceNow already and are looking to solve regular or unique problems that surface when using ServiceNow, then this book is for you. It's advisable to have a basic level of administration experience with ServiceNow. Familiarity with JavaScript is assumed. To get the most out of this book ServiceNow is cloud-hosted enterprise-level application, so you only require a standard browser (Internet Explorer/Firefox/Safari/Google Chrome) to access it. Apart from your organization's ServiceNow instance, you can claim your personal ServiceNow instance by registering at this link https://developer.servicenow.com. 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 from https:// www.packtpub.com/sites/default/files/downloads/ServiceNowCookbookSecondEdition_Colo . rImages.pdf Conventions used There are a number of text conventions used throughout this book. : 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: "Here's some sample code that leverages the GlideSystem library." CodeInText A block of code is set as follows: var requestBody = ""; var client=new XMLHttpRequest(); client.open("get","https://dev41882.servicenow.com/api/now/table/u_fulfillment? sysparm_query=sys_id%3Db778b2434f5a0300bbf9b7a18110c783&sysparm_limit=10" ); 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: "Click Submit to save the workflow." Warnings or important notes appear like this. Tips and tricks appear like this. Sections In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How it works..., There's more..., and See also). To give clear instructions on how to complete a recipe, use these sections as follows: Getting ready This section tells you what to expect in the recipe and describes how to set up any software or any preliminary settings required for the recipe. How to do it… This section contains the steps required to follow the recipe. How it works… This section usually consists of a detailed explanation of what happened in the previous section. There's more… This section consists of additional information about the recipe in order to make you more knowledgeable about the recipe. See also This section provides helpful links to other useful information for the recipe. Get in touch Feedback from our readers is always welcome. General feedback: Email feedback@packtpub.com 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 questions@packtpub.com. 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 copyright@packtpub.com 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. Getting Started with ServiceNow In this chapter, we will cover the following recipes: First steps with ServiceNow application ServiceNow frontend navigation ServiceNow backend navigation ServiceNow essential modules (ITIL) Managing your profile in ServiceNow Introduction ServiceNow is currently the market leading IT Service Management platform, but what exactly is ServiceNow, and what does it offer? ServiceNow is a cloud-based enterprise platform with a portfolio of services. As of the most recent release, ServiceNow has five major applications, covering IT, Security, Finance, HR, and Facilities. Most companies that adopt the platform begin in the IT Service Management space. Once on board, they'll quickly see opportunities in IT Operations Management, with applications like Discovery and Orchestration, or IT Business Management, with solutions like Project Management. Conversations we have around the platform generally start with ITSM/ITIL, but that's barely scratching the surface of what the platform can do. Each module is extensible individually, and you can readily add your own custom functions and solutions to address specific needs within your business. Opportunities exist for independent consultants and developers to share and publish their own applications using the ServiceNow Share portal, as well as the ServiceNow Store, and the platform is specifically postured to be lightweight and mobile-ready. So, where does our journey begins? Our first recipe will focus on provisioning our own individual instance of ServiceNow and getting accustomed to the environment. First steps with ServiceNow application Customer adoption of the ServiceNow platform has been surging over the past few years, but it's important to remember that each customer has its own expectations of how the platform will be used and adopted. One important design point to remember is that ServiceNow is intended to facilitate the adoption of the Information Technology Infrastructure Library (ITIL) practice framework. ITIL describes an integrated and process-based best practice framework for managing IT services. The recipes in this chapter will give you an overview of the ServiceNow modules that implement the ITIL v3.0 framework. Getting ready To get the most out of ServiceNow, knowledge of JavaScript and basic database concepts will help you greatly. Please keep in mind that as an admin or developer, you are not allowed to directly access the database layer, application layer, or hosts where the application runs. However, there are powerful options to utilize client and server-side scripts and REST and SOAP API activities, as well as a robust yet easy to use business logic infrastructure. How to do it... ServiceNow offers a private developer instance to those who register on the Developer Portal. 1. Navigate to https://developer.servicenow.com to register and request an instance: Once you've registered on the website, you can request an instance from the landing page. At the time of writing, instances are available in Helsinki, Istanbul, and Jakarta. 2. To use the latest and greatest, we'll go with Jakarta: Each developer instance has a unique host identifier and comes pre-installed with most OOTB functions, as well as some sample user data and work products. Additionally, you can use this management screen to install additional plugins, depending on what your current area of research or experimentation is. More on that will be covered in the later chapters. 3. Credentials for the admin account will be provided once the instance is provisioned. You will be prompted to change those credentials once you log in for the first time. Configuring LDAP authentication While local user management and authentication is available by default, most environment owners want to map their authentication process to their own Directory Service or Identification Provider (IDP). Multiple platforms are supported, including Microsoft Active Directory, Microsoft Azure, and Amazon Web Services: 1. To configure your LDAP provider, you'll navigate to System LDAP | Create New Server in the navigation bar: 2. On this screen, you'll enter the parameters for your directory service (usually provided by the identity services administrator): 1. Server name: An arbitrary name that will be displayed in lists and in record details. If you will have multiple LDAP servers, then pick names that help you to identify the server being used. 2. Server URL: This is the combination of the server name and server port where your LDAP server is listening. 3. Starting search directory: The Starting search directory or Relative Distinguished Name (RDN) where you want ServiceNow to begin its search for users and/or groups. This is an optional step for the remainder of this book. However, if you want to experiment with directory services, I would recommend provisioning a cloud-hosted service from Azure or AWS. Unless your environment's directory service is cloud-hosted, the server URL you provide will need to be publicly available. Alternatively, LDAP can be configured through an MID server. (More on that will be covered in the later parts of the book.) 3. Every named account in ServiceNow is represented on the Users table, which can be found under System Security | Users and Groups | Users: As you can see, the private developer instance provides a substantial list of sample users for experimentation. Also, new users can be added and removed as needed. It is useful to decide on a convention early on for what will be required to populate a user record. For example, users cannot receive email notifications without an email populated. 4. Once you have a user populated in ServiceNow, how do you determine what they'll be allowed to do? You will accomplish this through Roles and Groups: 1. Roles: This is a statement of rights/privileges within the ServiceNow system. Each module usually has several types of roles that designate the ability/responsibility to fulfill certain tasks and operations within the system. 2. Groups: This is a logical grouping of users according to shared responsibilities. Groups can be assigned tasks or other work products within ServiceNow and are usually assigned roles based on the duties of that particular group. One best practice to adopt in this space is to create Groups based on your organizational structure with the necessary users, then to assign Roles to the Groups. This makes keeping track of rights within the system simpler and more predictable than directly assigning Roles to individual users. Let's take a moment to walk through an example: 1. Within your developer instance, navigate to System Security | Users and Groups | Groups and click the New button. 2. Within the Group - New record form, give the new group a name and a description, then click Submit: 3. Once the group is created, you can add some Group Members. Within the newly created group, select the Group Members tab and click Edit... : The Edit Members screen is what ServiceNow devs colloquially call a slush-bucket. It's a dynamic interface where you can quickly create many-to-one relationships between rows on one table (Users) and another (Group). You'll see these quite a bit on your ServiceNow journey. 4. Currently, our sample data user Abel Tuter has no group or role memberships. Let's add him to our new group. Select his name and then click the right-arrow button. Then click Save. 5. Once you've saved, click on Abel's user record to see his memberships: Once you've navigated to Abel's user record, you can see that he has the group membership, but no roles (meaning rights) within the system. If he's going to be able to do any useful work, he will need to have a role within the system. You might think that the easiest way to do this is to simply assign him the role, much like we did the group. However, from a longterm perspective, it's easier to manage rights within ServiceNow by pre-populating groups with the necessary roles. This saves a lot of manual work with role assignments and also removes unnecessary rights from individuals if they leave the group at a future date. 6. To update the group, let's navigate to System Security | Users and Groups | Groups and find Abel's group. Once there, we will select the Roles tab and click Edit... : 7. Within the slush-bucket, let's add the itil role to our group. Then click Save: 8. Now, here's something interesting. By assigning the role to Abel's group, his user record has been pre-populated with the additional roles that come along with the itil role. Definitely a time-saver! There's more... The IT Infrastructure Library (ITIL) is an integrated, process-based, best practice framework for managing IT services. It provides assistance for the creation and functioning of a Service Desk that provides an efficient means of communication between the user community and the IT provider. It was originally started off to improve IT Service Management for the UK central government, and it has become a standard for many organizations: public or private sector, large or small, centralized, or distributed. To read more about the ITIL framework, please navigate to ht tps://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/pr . oduct/configuration-management/concept/c_ITIL.html See also Developer Portal: https://developer.servicenow.com Roles: https://docs.servicenow.com/bundle/jakarta-platform-administration /page/administer/roles/concept/c_Roles.html Groups: https://docs.servicenow.com/bundle/jakarta-platform-administrati on/page/administer/users-and-groups/concept/c_Groups.html ServiceNow frontend navigation Now that we've gotten our feet wet with some ServiceNow basics, it's time to take a step back and look at some of the components of the ServiceNow interface. Getting ready When users log in to the system, they will usually be met with one of several landing pages. Let's see what Abel Tuter gets now that he's an ITIL user. How to do it... 1. When Abel logs in to the system, he will have access to the ITIL home page. This home page provides several useful visualizations (commonly called widgets), such as work assigned to his new group or to him individually. Also, it provides other useful information, such as overdue tasks or tasks of critical priority: What's cool about these home pages is that each user can edit them to suit their own needs. 2. Let's say Abel isn't terribly concerned about items that aren't associated with his group. He can modify his version of the home page to remove items that he doesn't feel are relevant. To do this, Abel will hover in the upper-right corner of the widget and click the Close button that appears. He can do this on any of the widgets that don't interest him. 3. After Abel's done this a few times, he decides that he wants to add an additional widget to help him keep track of incidents that have been assigned to his group but haven't been assigned to an individual for attention. To do this, click Add content. 4. Within the Add content interface, select Gauges | Incident | My Groups Unassigned Incidents and select the bottom Add here section. This will place the new widget below others on the page: 5. Ahhh, much better! Now Abel has a simpler home page interface that will display information relevant to him at the beginning of each session. The Nav Bar Another important part of the user interface is the Nav Bar. The Nav Bar allows users to filter available selections to find relevant modules. Additionally, the Nav Bar allows users to favorite important modules for later reference. Let's say Abel wants to quickly find a link to add a new incident. He can type Incident in the filter menu to narrow his available choices. For even quicker navigation, any of the links in the Nav Bar can be selected as a favorite by starring the link. Now, when Abel wants to filter by favorites, he can select the Favorites tab in the Nav Bar. We can now see the Incident - Create New link is available without additional filtering. The Service Portal Now that we've spent some time navigating the native ServiceNow application, we will take a moment to talk about the new Service Portal. The Service Portal is a newer feature introduced in the Helsinki version of ServiceNow. As per ServiceNow's knowledge base, the Service Portal is once of the newer additions to the platform and a simple way to create portals for end users. It is a portal framework that allows administrators to build a mobile-friendly self-service experience for users. It interacts with parts of the ServiceNow platform, so users can access specific platform features using the Service Portal. Here's a peek at the Service Portal that ships with ServiceNow: The reason we are bringing this up early is that the Service Portal will likely be the first (and possibly only) experience inside of your environment, and developing with that in mind is vital. Low or no-code administrators can configure and modify Service Portal pages with minimum effort. But for any deeper development in the portal, knowledge of JavaScript and AngularJS is very useful. We will cover Service Portal development in a later chapter of this book. ServiceNow backend navigation So, we've taken a look at the frontend of ServiceNow; what about the backend of the system? The backend database structure and business logic engine of ServiceNow is optimized for access through the web, primarily through REST web service transactions. How to do it... Let's cover some of the basics first: Tables All work products in ServiceNow, whether a task or block of code, are stored on a table. While the system comes with several fully realized applications to address ITSM and other business goals, inevitably, organizations will see the need to either extend existing functionality or add entirely new solutions. The base table of ITSM core processes is called task. All of the Core ITSM applications share basic elements, like a unique identifier, assignment elements like group and user, requester information like who opened the task, and so on. It is a best practice that any new tables that fit this module should extend the task table or something similar to avoid duplication of efforts and redundancy/clutter in the database layer. So, let's say we have a customer who wants to build a new type of task called a Fulfillment Task. We can extend the existing task table to leverage all of the elements and logic associated with the task table while being able to add our own modifications without cluttering up the base table: 1. To do this, let's type tables in the Nav Bar filter and select the Tables link under System Definition: 2. Once you have the Tables list view open, click the New button. 3. Once you have the New Record screen for a table, fill out the required fields, remembering to select the Task table under Extends table. You'll notice that a new application link and menu will be created in the Nav Bar for us: 5. Under the Controls tab, select Auto-number. This will give the table a sequence and unique prefix for these tasks for easy reference. You'll also notice that a unique role will be created specifically for this table. We will study more on this in a later chapter. 6. Once you've finished filling out the form, click Submit: 7. After you click on Submit, the system will take a short time to create the table and other elements. Once it's complete, you should find our new application name in the Nav Bar using a simple filter. Records Well, we've got a table. Now what? Let's create a record to test with: 1. Click New on the Fulfillments list view. 2. None of the fields are required right now, but let's fill out a few, including adding Abel Tuter in the Assigned to field. Then click Submit: 3. Now that Abel has some work, let's open the record to see what he sees: Whoops! Abel can't see the Fulfillment module! If you remember, this new table had a unique role added to it when we created it. Only individuals that have this role are able to see this module and records within it. Let's fix that now by navigating to Groups (as a System Administrator). 4. Click Edit... on Roles in the IT Fulfillers Group: 5. In the Roles slush-bucket, find the table role that was created along with the table. One trick for this is to type u in the filter. All user defined tables and elements, such as columns and roles, will be prefixed with u_: 6. Once you've added the role, click Save. 7. Now that you've updated Abel's group to have the role associated with your new table, he should be able to see the record: So, if we can create all the tables and records that we want, how do we avoid collisions in naming and numbering conventions? ServiceNow solves this by assigning each record a unique table sequence ID. 8. The easiest way to get this value from the UI is to right-click on the record header (light gray bar) and select Copy sys_id from the context menu. Let's see what value we get: 9. The sys_id for this record is b778b2434f5a0300bbf9b7a18110c783. Another way you can find this is by looking at the URL and extracting the sys_id element from the query string: You will use the sys_id of records frequently when using web services or when scripting within the environment. ACLs Let's take a look at data layer level security on tables. The following shows how we can learn more about the tables that we'll be working with in the future: 1. We can find a list of Access Controls (ACLs) in the same record context menu: While you can view ACLs in this view, you will need to elevate your admin role to security_admin to make any changes. You can accomplish this by selecting Elevate Roles under your Profile menu. 2. Check the security_admin box and then click OK: 3. Let's look at the read record associated with our custom table role: ACLs control the basic create, read, update, and delete (CRUD) database operations. Normally, you won't be controlling things this granularly, but it's useful to understand the security layer of the data in case you're stumped on granting or restricting access. Note that the Admin overrides field is checked in this instance. That means that any user with the admin role will bypass this rule. It's possible to add rules that restrict access even to admins but ensure there is a good reason for implementing a rule like this. Good justifications include privacy and other compliance requirements. Workflow Editor Now that we've created a custom table and defined who will be creating them, what about the life cycle of these new tasks? Should certain things be required once a fulfillment is underway? Will approvals be required? Will they expire after a certain amount of time? That's where we'll define a workflow: 1. Navigate to the Workflow Editor through the Nav Bar. When you click the link, it will open in its own window. The Workflow Editor is an interface for creating and modifying workflows by arranging and connecting activities to drive processes. You can manage multiple workflows on the same screen, create custom workflow activities, and use existing activities as data sources. Users with the workflow_creator role can create workflows. Users with the workflow_admin role can create, modify, delete, and publish workflows. 2. For now, let's create a basic workflow for a fulfillment. Click on the + button in the upper-right corner. 3. In the New Workflow interface, populate the Name with something straightforward and select Fulfillment[u_fulfillment] for our Table: You'll notice that we're setting the workflow to Run the workflow always. That means that this workflow will apply every time a fulfillment record is created in our system. Multiple workflows can apply, but let's keep it simple for now. 4. Click Submit to save the workflow. You'll start with a basic flowchart diagram within which you can add activities from the sidebar. Click the Core tab to see some of the categories: 5. Let's say our Fulfillment task is going to have two steps. One to gather requirements and one to complete requirements. We will need to start with a Create task activity after Begin. Find the Create Task activity under Tasks, then click and drag it to the flowchart to add this task. This will open the New Activity: Create Task form. We will want to name the activity and give it some parameters for creation. Once you've added them, click Submit: 6. Follow the same process to create the Complete Requirements task: 7. Once you've added the tasks, highlight and delete the flow arrow between the Being and End steps, then drag and connect each of the new steps as follows: Begin | Gather Requirements Task | Complete Requirements Task | End: It looks like we have a completed wireframe for the fulfillment workflow, but I'd like to add a couple more activities. Notably, this will be keeping the Fulfillment State field current with the actual tasks that are being completed. 8. We'll do this using the Set Values activity under Utilities. Drag two of them to the flowchart space with the following parameters: 9. Now, let's wire up our new activities with some flow arrows: 10. And then we can Publish our new workflow using the context menu. 11. As the effects of workflows are not retroactive, to see the effects of our workflow, we will need to create a new Fulfillment record. Let's do that next: 12. Well, we can see the Fulfillment record, but what about the tasks that are created and managed by the workflow? For that, we'll need to add a Related List using the context menu. 13. The Related List we want to add in this case is the Task | Parent list. Add it using the slush-bucket. Then click Save: 14. That's much better! We'll cover more on Related Lists and other UI elements in Chapter 2, Performing Core Configuration and Management Tasks. One more thing to remember is that you can have more than one workflow apply to the same piece of work product. In this way, you can keep responsibilities separated between smaller workflows. You may find this approach easier to manage over time. REST API Explorer One more interesting tool I want to touch on is the REST API Explorer. This tool is a useful interface for getting your feet wet with making REST calls into the ServiceNow system, and probably the first thing you should use to prototype new integrations into your system: 1. To find this tool, look under System Web Services | REST | REST API Explorer. Using this tool, you can perform all the normal CRUD operations on the DB layer, provided you have the requisite permissions. 2. As an experiment, let's GET the first Fulfillment record we created earlier. Use the following parameters and click Send. 1. tableName: Fulfillment (u_fulfillment) selected from drop-down menu 2. sysparm_query: sys_id=b778b2434f5a0300bbf9b7a18110c783 (Use the sys_id you copied from the record in the previous record creation recipe) 3. If your REST query is valid, you'll receive a response that includes the HTTP code, header information, and the response body. Here's the sample from my test: Response Body: { "result": [ { "parent": "", "made_sla": "true", "watch_list": "", "upon_reject": "cancel", "sys_updated_on": "2017-11-12 19:43:16", "approval_history": "", "number": "FUL0001002", "sys_updated_by": "admin", "opened_by": { "link": "https://dev41882.servicenow.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441", "value": "6816f79cc0a8016401c5a33be04be441" }, "user_input": "", "sys_created_on": "2017-11-12 19:43:16", "sys_domain": { "link": "https://dev41882.servicenow.com/api/now/table/sys_user_group/global", "value": "global" }, "state": "1", "sys_created_by": "admin", "knowledge": "false", "order": "", "closed_at": "", "cmdb_ci": "", "delivery_plan": "", "impact": "3", "active": "true", "work_notes_list": "", "business_service": "", "priority": "4", "sys_domain_path": "/", "time_worked": "", "expected_start": "", "opened_at": "2017-11-12 19:42:58", "business_duration": "", "group_list": "", "work_end": "", "approval_set": "", "work_notes": "", "short_description": "Test Fulfillment", "correlation_display": "", "delivery_task": "", "work_start": "", "assignment_group": "", "additional_assignee_list": "", "description": "Fulfill this Request", "calendar_duration": "", "close_notes": "", "sys_class_name": "u_fulfillment", "closed_by": "", "follow_up": "", "sys_id": "b778b2434f5a0300bbf9b7a18110c783", "contact_type": "", "urgency": "3", "company": "", "reassignment_count": "0", "activity_due": "", "assigned_to": { "link": "https://dev41882.servicenow.com/api/now/table/sys_user/62826bf03710200044e0bfc8bcbe5df1", "value": "62826bf03710200044e0bfc8bcbe5df1" }, "comments": "", "approval": "not requested", "sla_due": "", "comments_and_work_notes": "", "due_date": "", "sys_mod_count": "0", "sys_tags": "", "escalation": "0", "upon_approval": "proceed", "correlation_id": "", "location": "" } ] } By default, the response body will be in JSON format. Alternatively, you can request that the body be supplied in XML. 4. You might have also noticed that the REST API Explorer provides code samples to execute these same calls outside of the ServiceNow environment. Click on any of these hyperlinks to pull up a dialog box with the sample code. 5. Here is the JavaScript code you might use to make this same call from a third-party environment: var requestBody = ""; var client=new XMLHttpRequest(); client.open("get","https://dev41882.servicenow.com/api/now/table/u_fulfillment? sysparm_query=sys_id%3Db778b2434f5a0300bbf9b7a18110c783&sysparm_limi t=10"); client.setRequestHeader('Accept','application/json'); client.setRequestHeader('Content-Type','application/json'); //Eg. UserName="admin", Password="admin" for this code sample. client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin')); client.onreadystatechange = function() { if(this.readyState == this.DONE) { document.getElementById("response").innerHTML=this.status + this.response; } }; client.send(requestBody); See also Tables: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/pa ge/administer/table-administration/task/t_CreateATable.html ACLs: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/pag e/administer/contextual-security/concept/access-control-rules.html Workflow Editor: https://docs.servicenow.com/bundle/jakarta-serviceno w-platform/page/administer/workflow/reference/workflow-editor.html REST API Explorer: https://docs.servicenow.com/bundle/jakarta-servi cenow-platform/page/integrate/inbound-rest/concept/c_RESTAPI.html ServiceNow essential modules (ITIL) Now that we've learned some fundamentals about how the ServiceNow platform operates, what should we know about the purpose of the ITSM/ITIL application? The ITIL catalog encompasses much more than what's included in this section. How to do it... I consider the fundamental modules of ITSM to be the Core Four: Request Management Incident Management Change Management Problem Management Knowledge Management Let's spend a little time on those. Request Management ITIL defines a service request as, A request from a user for information, or advice, or for a Standard Change or for Access to an IT Service. Basically, it is any routine request from an end user that does not involve resolving a degraded service or otherwise restoring functionality. Service requests usually follow repeatable processes that can be scripted or automated. ServiceNow provides access to these types of tasks through the Service Catalog. Users also have access to the same catalog items through the Service Portal. For now, let's take a look at the Catalog inside of the native ServiceNow application: 1. Navigate to Self-Service | Service Catalog. On this screen, we will see several sample categories, within which we can log different requests for ourselves or on behalf of other users. 2. Let's walk through entering a hardware related request; click Hardware: Here we can see a list of options where we can request new or replacement hardware. Let's get ourselves a new developer laptop. 3. Within this form, we get an overview of the specs of our new laptop and options to request additional software, if we so desire. Let's ask for the Eclipse IDE to be pre-installed on our new droid. Then click Order Now: 4. Voila! Our request has been generated and our new laptop should be on order. This screen shows us a link to the actual request task and shows us some expectations for when to expect it: 5. Let's click on the Request Number hyperlink to see what the request task itself looks like: This is the Request screen. A request in ServiceNow represents one completed session of a user within the Service Catalog. Since the Service Catalog has shopping cart functionality, it's possible to submit multiple quantities of the same item, or request multiple catalog items in the same request. If multiple items are requested, this will be reflected in the Requested Items (RITM) tab at the bottom of the screen. Each item in the catalog is defined by Request Administrators according to specs outlined by the owners of the fulfillment processes of those individual items. Each item has a set of variables to fill out (like the Eclipse option we selected) and one or more underlying workflows that determine the life cycle and steps of the request. We'll cover more on building these in Chapter 6, Creating and Configuring Workflow Activities and Chapter 8, Service Portal. Incident Management ITIL defines an incident as, An unplanned interruption to an IT Service or a reduction in the quality of an IT Service. Essentially, an incident is a task that's logged when something's broken. A workstation could be failing or a website could be down. No matter the root cause, the goal of Incident Management is to restore the failing node to service as soon as possible. This can come through a repair or through a workaround. Have you tried turning it on an off again? This is a valid and common attempt at Incident Management. So, how do users log an incident? Generally, an organization's Service Desk would be responsible for initial triage when a service degradation is reported. They would then gather the necessary information and route the incident to the appropriate group. Let's see how incidents are logged in ServiceNow: 1. Navigate to Incident | Create New. Abel Tuter has called the Service Desk to report that his Flux Diode is acting up. Our stalwart Service Desk personnel lack the necessary knowledge to resolve Abel's issue, so they log an incident and route it to the Hardware group: 2. Once this incident is logged, notifications go out to the Assignment group members so that someone can respond to Abel's incident. Let's add some information indicating what the Hardware group did to resolve it: Now that Abel's Flux Diode is working again, it's time to resolve the incident, right? Not so fast! Couldn't the Service Desk have just as easily tried the same resolution to Abel's issue? Let's ensure this incident is flagged so that an article can be added to the organization's knowledge base for future reference. 3. Select the Resolution Information tab and check the Knowledge box. Then click Resolve: You may need to click Update or Save. Afterwards, the Incident will be resolved. Change Management ITIL defines a change as, The addition, modification or removal of anything that could have an effect on IT Services. Change Management can be a blessing or a bane, depending on how it's implemented and viewed within an IT Organization. The basic idea of Change Management is to be transparent about what's being modified within your infrastructure and when. Sometimes it's a gatekeeping process, and other times it's an open discussion of action items. Ideally, it's some of both: 1. So, how does ServiceNow handle Change Management? Let's take a look by navigating to Change | Create New: 2. Out of the box, the Create New Change screen prompts us to identify what type of change we are requesting. Our options are: 1. Normal: Changes without predefined plans that require approval and CAB authorization. 2. Standard: Selected from available pre-approved change templates. These changes do not require approval. 3. Emergency: Unplanned changes necessary to restore service. These changes require CAB authorization only. Most IT organizations will have scenarios meeting any of the above criteria. Ideally, emergency changes will be kept to a minimum, but organizations should always have a process in place in anticipation of those events. For now, let's stick to a normal change. 3. Depending on your organization's needs, you'll likely have several stakeholder representatives making up your Change Advisory Board (CAB) that will help prioritize and advise on scheduled change requests. Each organization may have differing requirements of planning or scheduling, including what must be disclosed and how far in advance changes should be scheduled: 4. Once the change request is drafted and ready to submit, the requester will click Request Approval, which will start the Change Management approval and review process according to how the organization has defined it internally. For further information on Change Management processes and configuration, please check the reference link in the See also section of this recipe. Problem Management ITIL defines a problem as, A cause of one or more Incidents. Let's say you have a major incident that affects multiple sites, or even your entire organization. Or maybe the Service Desk is tired of Abel calling them about his Flux Diode. You'll address these scenarios through Problem Management. Problem Management can be viewed as root cause analysis of one or more incidents. Depending on the value or time savings that would come along with eliminating the major or repeat incidents, it may be valuable to spend some time doing a deeper dive into the root cause and putting a stop to these events. Let's create a Problem Management request for Abel's incident. While we could navigate to the problem module directly, it's more useful to create the problem directly from the incident in question: 1. Open any incident from the Incident list screen and right-click the context menu in the header bar. Click Create Problem: 2. This action creates the entire problem record without further user intervention. From here, the problem can be assigned to a group for attention, depending on your organization's processes: 3. One additional advantage to logging the problem through the Incident context menu is that it automatically creates a relationship back to the incident for easy reference. Additional relationships to incidents or other work products can be created to ensure that complete information is available to the problem management personnel: Knowledge Management There's a running joke in application development which goes, Everyone wants documentation. They just don't want you to spend any time on it. This is no different in IT Service Management. Knowledge Management and other documentation almost become afterthoughts in favor of building new functions or running to put out the next fire. In truth, Knowledge Management is a key value-add to any IT organization and is vital for initiatives like Knowledge Centered Support and Case Deflection. Do not neglect your Knowledge Management process! Remember that Knowledge checkbox we selected when resolving Abel's incident? Let's ensure we capture the lessons learned from that incident for future reference: 1. The first thing we'll need to do is close the incident. We can navigate to that incident and click Close Incident. You'll see a message like the following: 2. To find our new article, navigate to Knowledge | Unpublished. It should be available in the list view: 3. Inside the article, you can add additional information and attachments (screenshots) of the error and how to resolve it. Additionally, you can schedule the article to expire at a future date or require that it be reviewed periodically. This ensures that your knowledge base isn't getting cluttered or stale. Click on Publish to publish our article: What's cool about Knowledge Articles in ServiceNow is not just that they are searchable in the Service Portal or global search, but that they also show up as suggestions when logging a new incident or other task that references the knowledge base. 4. Let's attempt to open a new incident that references the topic of our new article: Look at that! Now that we've captured knowledge from previous incidents, our Service Desk has the proper information available to address customer issues without forwarding an incident to another group. Definitely, keep Knowledge Management in mind throughout your ITSM and other ServiceNow implementations. See also Request: https://docs.servicenow.com/bundle/jakarta-it-service-managemen t/page/product/planning-and-policy/concept/c_RequestManagement.html Incident: https://docs.servicenow.com/bundle/jakarta-it-service-managemen t/page/product/incident-management/concept/c_IncidentManagement.html Change: https://docs.servicenow.com/bundle/jakarta-it-service-managemen t/page/product/change-management/concept/c_ITILChangeManagement.html Problem: https://docs.servicenow.com/bundle/jakarta-it-service-manageme nt/page/product/problem-management/concept/c_ProblemManagement.html Knowledge: https://docs.servicenow.com/bundle/jakarta-servicenow-platf orm/page/product/knowledge-management/topic/p_KnowledgeManagment.html Managing your profile in ServiceNow One more item to close out our chapter involves managing your profile in ServiceNow. While it would be nice to depend on automation and other tool driven options to determine our experience, it is important for users to understand what they can control around their user record. How to do it... In this section, we will cover some basics around controlling your own experience within ServiceNow. User profile 1. To access your profile in ServiceNow, use the Profile context menu in the upper-right corner. 2. On your profile screen, you can modify some basic localization items, like how you'd like to see Date/Time fields or what your Time zone is. You can also add a profile photo or select a Language for localization. Notifications One important part of the user experience is controlling when and how you'll receive notifications from ServiceNow. There are literally hundreds of out-of-the-box emails notifications for the various modules, and users can feel overwhelmed by the sheer volume of email or texts coming out of the system: 1. To make changes to notifications, click the Settings gear icon in the upper-right corner, as shown in the following screenshot. 2. Then select the Notifications tab in the left-hand menu: Depending on what notifications you want to turn on or off, you can select the appropriate module and toggle the notification you'd like to stop receiving. Impersonation One more important profile related function is Impersonation. Generally, developers or other admins will use impersonation to test changes that they make to the system. Sometimes, these changes will be that certain fields are visible or required, depending on who the audience is: 1. You might have noticed some impersonation of Abel Tuter during this chapter. To impersonate a user, use the profile context menu again, and click Impersonate User. 2. This will pull up a search menu where you can select any user record to impersonate. 3. To return to your own profile, select Impersonate User again and select your own profile name. See also Notifications: https://docs.servicenow.com/bundle/jakarta-servicenow-pla tform/page/administer/notification/reference/notifications.html Impersonation: https://docs.servicenow.com/bundle/jakarta-platform-adm inistration/page/administer/users-and-groups/concept/c_ImpersonateAUser.ht ml Performing Core Configuration and Management Tasks In this chapter, we will cover the following recipes: Setting up your basic configuration Configuring ServiceNow forms Configuring UI policies on ServiceNow forms Configuring UI actions on forms Using ServiceNow plugins Understanding ServiceNow tables schema Getting into the CMDB Understanding the system dictionary Setting up an SLA or other contracts Setting up system rules Understanding deployments or update sets Introduction After purchasing ServiceNow, the customer receives one production instance and two non-production instances. These are vanilla instances and require configuration according to your organization's requirements. In this chapter, you will learn how to perform core configuration and management activities. Setting up your basic configuration It's important to note that each and every organization has its own marketing and branding policies for IT applications. The basic configuration is an essential part of a ServiceNow instance. You'll need to configure the entire ServiceNow website for end users. If you're an ITIL user of the system (able to see The Core Four of modules), you are allowed to change the theme of ServiceNow and re-arrange the application pane at your convenience. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com. 2. If you want to change the logo of the ServiceNow instance then, on the left-hand side in the search box, navigate to System Properties | Basic Configuration U16, and then click on the + sign next to the Banner Image: 3. This will open up a file selection dialog where you can select your new logo. Click Open to accept: 4. Then click Save to apply your changes. Once you click your home page icon, the image should refresh. 5. If you'd like to go a little further and apply a theme to ServiceNow that matches your company's branding, navigate to System Properties | Basic Configuration U16. 6. If you're knowledgeable about Cascading Style Sheets (CSS), you're more than welcome to design your style elements, or you can use the following code: 1. Header background color: #0573f6 2. Header divider stripe color: #6c813f 3. Background for navigator and sidebars: #6c813f Once you've saved your settings, you'll need to refresh your browser to see the results: See also CSS and themes: https://docs.servicenow.com/bundle/geneva-servicenow-platform/ page/administer/navigation_and_ui/concept/c_CSSThemeSupport.html Configuring ServiceNow forms The configuration of forms in ServiceNow is an important task as it determines what the user sees when they open a record. In this recipe, you will see how you can configure the form according to your needs. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you have provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. We are configuring the incident form in this recipe, but you can similarly configure any other form. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com. 2. Navigate to Incident | Create New. Once inside the new record form, right-click on the gray header bar to access the context menu. Select Configure | Form Layout. 3. From the Form Layout slush bucket, you'll have several options to modify the form, as shown in the bullet list given here: 1. Available: This holds all the tables' variables or fields, and you can move any fields on the form. 2. Selected: This holds all the fields that are visible on the form. 3. View name: There may be more than one view associated with the form. A view controls the fields on the form that appears when a user opens a form or a list. 4. Section: Forms are divided into sections, as shown in the following screenshot. Sections are just a way to logically group fields. 5. Create new field: This is where you would name a new field to be created. While I prefer using the Table interface to create columns, this is a good place to both create a field (column) and add it directly to the form. This will save you time: 4. Let's use this interface to create a new field. Fill out the Form Layout fields as follows and then click Add: 1. Name: Age In Days 2. Type: Integer 3. View Name: Default view 4. Section: Notes This will add the field to the selected section. You can then click Save. 5. A short process will run, indicating the backend table modifications, prompted by our new field. This will be followed by a confirmation. 6. Once you click Close, you will be able to find your new field in the section from the field creation: This is just a simple demonstration of modifying the table and the UI in a single step. Frequently, your users are going to request changes like these. Before long, this will be a routine task for most ServiceNow developers. There's more... It is important to note that the Form Layout option is available under Configure for all forms through the context menu. This will allow you to make immediate changes to any interface you like as you navigate through the platform. While Form Designer is also available from the same context menu, you should refrain from using it unless absolutely necessary. Changes you make in that tool can cascade down to parent tables such as Task. See also Configuring forms: https://docs.servicenow.com/bundle/jakarta-platform-adminis tration/page/administer/form-administration/concept/basic-form-administration.html Configuring UI policies on ServiceNow forms UI policies modify the behavior of a ServiceNow form. Examples of this are: setting a field to read-only access, hiding or showing a field, or making a field mandatory. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. We are configuring the Incident form in this recipe, but you can similarly configure any other form. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com. 2. Then navigate to Incident | Create New. Once inside the new record form, right-click on the gray header bar to access the context menu. Select Configure | UI Policies: This will take you to the list view of UI Policies that apply to an Incident. You'll then Click New. 3. Let's say that our customer wants the resolution notes and resolution code to be required when an Incident is resolved. We can implement this by filling out the UI policy as follows: 1. Table: Incident (this should already be set if you've followed the preceding steps) 2. Active: Checked (True) 3. Short description: Make Resolution Info Mandatory On Close 4. Order: 100 5. Conditions: State | is one of | Resolved and Closed: You can multi-select the states by holding Alt and clicking with the mouse. 6. Leave everything else as the default 4. Once you have completed the UI Policy, click on Submit: 5. Now that we have the conditions of our UI Policy set up, it's time to add some actions. From within the UI Policy Record, click New in the UI Policy Actions section of the form. 6. Within the UI Policy Action form, select the drop-down under Field name. 7. This will open up a field selection dialog that lists all of the fields available on the form. For our first action, choose Resolution code: 8. This will populate the Field Name selection. Also, set Mandatory to True, then click Submit. 9. Repeat the preceding actions to add a UI Policy Action for Resolution notes: 10. Now that we've completed our UI Policy, let's navigate back to Incident | Create New to test it out. 11. Within the new Incident form, set the State to Resolved. The fields subject to the UI Policy should now show as mandatory (red asterisk when empty): See also UI Policies: https://docs.servicenow.com/bundle/jakarta-platform-administration/pa ge/administer/form-administration/task/t_CreateAUIPolicy.html Configuring UI actions on forms A UI Action is a form button used to map scripted actions from relevant forms. Examples of this are create problem or create change. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com. 2. Then navigate to Incident | Create New. Once inside the new record form, right-click on the gray header bar to access the context menu. Select Configure | UI Actions: 3. This will bring up a list view of all UI actions defined for the Incident form. Let's define a new one by clicking New. 4. Let's define our new UI Action as follows: 1. Name: Take This Task 2. Table: Incident[incident] (this should be automatically populated) 3. Action name: Take This Task 4. Active: Checked 5. Show insert: Checked 6. Show update: Checked 7. Form button: Checked (this will display our new UI Action as another button on the form) 5. Now we're going to paste in a little code to define what the UI Action actually does. Add the following to the Condition field: gs.hasRole('itil') || gs.hasRole('resolver') || gs.hasRole('admin') This will define who is able to see and use the UI Action button. Because customers are able to view the status of Incidents, we don't want them to inadvertently try to assign the Incident to themselves. 6. Add the following to the Script field: action.setRedirectURL(current); current.assigned_to = gs.getUserID(); current.setForceUpdate(true); current.update(); 7. This script will get information about the user currently viewing the incident. Update the Assigned To value to their user ID. Once you've finished pasting in the code, click on Submit. 8. Now that we've submitted the UI Action, it should be available to us in the Incident form: Try filling out a new incident and using the new UI Action button when you save. It should prepopulate the Assigned to value to your ID. See also UI Actions: https://docs.servicenow.com/bundle/jakarta-platform-administration/pa ge/administer/list-administration/concept/c_UIActions.html Using ServiceNow plugins While ServiceNow provides substantial functionality out of the box, there are a myriad of features that are deployed through plugins. In this recipe, we will deploy a plugin called Data Archiving that is not activated by default. As with any application, the data footprint of ServiceNow grows over time and customers often have no need to retain data once it passes a certain age. For example, an Incident more than a year old might no longer be needed. And retaining data for too long will affect the performance of queries and reports or expose organizations to other data retentionrelated concerns. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com and navigate to System Definition | Plugins. This will bring up the list view of system plugins. All plugins listed under System Definitions are free for customer use and do not require an additional license. 2. Let's find the Data Archiving plugin and activate it. Type data into the Name field and click Enter to search. Data Archiving should be at the top of the list. Click it to continue. 3. Within the Data Archiving record screen, click the Related Link | Activate/Upgrade to begin activation of this plugin. Even if an unused plugin is active, rerunning the activation process will ensure that you have the current version of the plugin resident and activated within your ServiceNow instance. 4. Click Upgrade on the Activate Plugin dialog: 5. A short plugin activation process screen will run, followed by a confirmation screen. Click Close & Reload Form to finish the activation: Data Archiving is now activated and ready to use! See also Activate a plugin: https://docs.servicenow.com/bundle/jakarta-serviceno w-platform/page/administer/plugins/task/t_ActivateAPlugin.html Data Archiving: https://docs.servicenow.com/bundle/jakarta-servicenowplatform/page/administer/database-rotation/concept/c_ArchiveData.html Understanding ServiceNow tables schema ServiceNow is an enterprise-level system, and it has its own data model and layer. Through the schema map, you'll be able to view how tables and fields interrelate in a visual representation. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, and then navigate to System Definition | Tables & Columns. 2. This will bring you to a master form where you can select any table, get a list of its columns (fields), and then view attributes about each. Let's select Incident under Table Names: 3. Let's select the Short description field to get an overview of its attributes. Most of these fields will make more sense to those with a DBA background, but I'd like to point out the Element and Element Table attributes: These fields identify the basic name and residence of the column. As covered in Chapter 1, Getting Started with ServiceNow, tables can either be created whole cloth or can be extended from existing tables. The Incident table has been created as an extension of the Task table. As such, all fields that are part of the Task table are included in Incident. Consequently, we cannot remove this field from the Incident table. However, we can always hide it from the form or relabel it to suit our needs. 4. Let's take a look at the Schema map for the Incident table. With Incident still highlighted under Table Name, click Schema map: The schema map is a helpful interface that will show you visually which tables directly reference your selected table. This can help you to plan your data model and the business logic that you build over it: This is only an overview of the potential of the database layer. While it's simplified and abstracted more so than a conventional database interface, you can accomplish most first pass optimizations and other DB tasks here. See also Schema maps: https://docs.servicenow.com/bundle/jakarta-platform-administratio n/page/administer/table-administration/task/t_GenerateASchemaMap.html Getting into the CMDB CMDB stands for Configuration Management Database. It's intended to be a representation of not only your physical and logical IT environment, but also an abstraction of all of the business services and capabilities of your organization. As organizations scale, keeping track of your entire environment becomes an unmanageable task for individuals alone. Additionally, automating and integrating information about your environment is vital for driving automation such as software deployments, asset lifecycle management, and vulnerability detection, to name but a few. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, and navigate to Configuration | CI Class Manager. 2. The base object of the CMDB is called a Configuration Item or CI. A CI can be literally anything in your environment: a node, a service, a location, an individual. To organize CIs, they are assigned to classes within the system. The Class Hierarchy list shows all of the base classes of the CMDB, each of which has its own table inherited from the CI table. Let's look at the Hardware class: 3. Clicking on Hardware brings up the Hardware table and shows us essential information about that table. One important note is that the Hardware table was extended from the Configuration Item table (cmdb_ci). 4. We've been having issues with Flux Diodes lately, but there isn't a class for them in our model. Let's create one under Hardware. 5. Click on the three horizontal line (or hamburger icon) next to Hardware and then click Extend. 6. Fill out the following fields and click Submit: 1. Label: Flux Diode 2. Name: u_flux_diode 3. Extends table: Hardware 4. Create module: Checked 5. Create mobile module: Checked 6. Add module to menu: Configuration 7. Our new Flux Diode table has been created. And, since we added a module for this class, it's also available in the Nav Bar: There's more... For those with an object-oriented programming background, this system of inheritance from base objects/models may seem familiar. For example: Computer is a Hardware is a Configuration Item. What's important to recognize is that these classifications can be used to drive behaviors and events in the system that are relevant to your organization. See also CMDB: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/produ ct/configuration-management/concept/cnfig-mgmt-and-cmdb.html Understanding the system dictionary The system dictionary is a master table that contains details for each table and definitions for every column/field on each throughout your instance. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, and then navigate to System Definition | Dictionary. 2. This will bring up the list view of all dictionary entries. Let's experiment a bit by creating a new entry. Click New. 3. Fill out the form as follows and then click Submit: 1. Table: Incident[incident] 2. Type: String 3. Column label: Reviewer Name 4. Column name: u_reviewer_name 5. Max length: 100 4. The Reviewer Name field is now available on the Incident table and can be made visible on the Incident form: See also System dictionary: https://docs.servicenow.com/bundle/jakarta-servicenow-platfo rm/page/administer/data-dictionary-tables/concept/c_SystemDictionary.html Setting up an SLA or other contracts In an IT support environment, support groups, vendors, and other fulfillers often work according to explicit agreements around response and resolution times. These contracts are usually referred to as Service Level Agreements (SLAs) or Operational Level Agreements (OLAs), or underpinning contracts. ServiceNow allows you to set these agreements up explicitly in the environment, with supporting timers and reminders. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, and then navigate to Service Level Management | Getting Started | SLA | SLA Definitions. 2. This will bring up the list of existing SLA records. Let's create a new SLA by clicking New. 3. SLAs require quite a bit of configuration. Fill out the following values on the new record form: 1. Name: SAP Service Issue 2. Type: SLA 3. Table: Incident[incident] 4. Workflow: Default SLA workflow (this should be autopopulated) 5. Duration: 4 Hours 6. Schedule: 8-5 weekdays 4. The Start condition of an SLA determines which incidents it will apply to. To narrow it down, click on the Start condition tab and enter the following: Start condition: State less than On Hold AND Business Service is SAP Enterprise Services As you can see, we have an On Hold state, which should pause our SLA. Under Pause condition, enter the following: Pause condition: State is On Hold Finally, we'll need to let the SLA know when it should stop running entirely. Under Stop condition, enter the following: Stop condition: State greater than On Hold Once you've completed this, click Submit. All incidents that fit these conditions will now have the defined SLA attached: See also SLAs: https://docs.servicenow.com/bundle/jakarta-customer-service-management/page /product/customer-service-management/concept/c_ServiceLevelAgreements.html Setting up system rules Out of the box, ServiceNow provides data lookup and assignment rules to automatically assign a task to users or groups. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance. For example, https://{instancename}.service-now.com and then navigate to System Policy | Rules | Assignment Lookup Rules. 2. This will bring up the list of existing Assignment Rules. Let's create one for the SAP Business Service, which will automatically assign incidents to a particular group. Click New. 3. We want every incident associated with the SAP service to be assigned to the Software group. Enter the following values on the new record form and then click Submit: 1. Category: Software 2. Configuration Item: SAP Enterprise Services 3. Assignment Group: Software Now any new incident created with these parameters will automatically be assigned to the Software group. See also Assignment lookup rules: https://docs.servicenow.com/bundle/jakarta-platformadministration/page/administer/task-table/concept/c_AssignmentLookupRulesExample.ht ml Understanding deployments or update sets Now that we've gone over quite a few enhancements and customizations of ServiceNow, you may be wondering how we can migrate them between environments. For enhancements and other changes made to the core applications, such as ITSM, we'll promote through update sets. An update set is a defined package of changes made within a particular environment. As mentioned in Chapter 1, Getting Started with ServiceNow, any ServiceNow customer gets three instances or environments. These environments are usually organized into the following categories: development, testing/QA, and production. New development work should be done in development. This work is then promoted to testing/QA for user acceptance testing or other evaluation. Once everyone is happy, the code is deployed into production. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, and then navigate to System Update Sets | Local Update Sets. 2. This will bring up the list view of all update sets currently in your instance. To create a new update set, click New. 3. Fill out the new record form as follows: 1. Name: Flux Diode Enhancement 2. State: In Progress 3. Description: Captures all of the enhancements necessary to fulfill Flux Diode Incidents Then click the button called Submit and Make Current: 4. Clicking Submit and Make Current will map your session and any changes made within it to this update set. You can keep track of the update set you're currently assigned to by enabling the Update Set dropdown in your user settings. 5. Click the gear icon in the extreme upper-right of the screen. 6. Inside the System Settings dialog, click Show update set picker in header in the Developer tab and then close the dialog: This will show the update set picker next to your username. The currently selected update set will display. 7. Let's say we've finished all of our updates appropriate to this update set and want to export what we've done for migration to another environment. Navigate to your update set and change the State field to Complete. Then click Update: 8. Your record will show as complete, and your assigned update set will revert to default in the update set picker. Next, click on Related Link | Export to XML. 9. This will open up a file explorer dialog where you can choose a name and location for your XML file. Now click on Save: 10. Now, we're only working with one instance here. But let's pretend that we're importing the same update set to our existing instance. Import your newly saved XML file by navigating to System Update Sets | Retrieved Update Sets. 11. Click on Related Links | Import Update Set from XML. 12. Once on the import XML screen, click Choose File to open up another filesystem dialog where you can find your previously saved XML. Once you've selected your file, click Upload to retrieve your update set to the instance. 13. Open the newly retrieved update set by clicking its name on the list view. You'll see that the State is Loaded. This means the update set is staged in ServiceNow, but not yet committed to the codebase. The update set must first be previewed and then committed. 14. Click the button Preview Update Set: 15. A short process dialog will run, which evaluates the code being imported and indicates any collisions or conflicts. Blue bars are good! Should you run into any collisions or conflicts, the import process will display a related list log indicating which parts of the import require attention. 16. Now the State is Previewed. We're ready to commit. Click the Commit Update Set button: Another process dialog will run. Again, blue bars are good! Keeping track of your update sets can be tricky and confusing at first, but you'll soon get the hang of it! There's more... It is important to note that data isn't captured by default in update sets. This includes information such as individual users or groups, or ticket data. It's possible to force this data through, but it must be done manually from the list view of the table containing the data. See also Update sets: https://docs.servicenow.com/bundle/jakarta-application-development/p age/build/system-update-sets/concept/system-update-sets.html Building and Designing DataDriven Applications In this chapter, we will cover the following recipes: Starting a new application Adding new components to your application Publishing a new application Using the Team Development plugin Getting into client scripting Getting into server scripting Understanding development best practices – script includes Understanding web services Implementing automated testing Introduction ServiceNow provides a great platform for developers who want to build, sell, or share their ideas on the platform. In addition to popular JavaScript frameworks such as Angular, ServiceNow also offers proprietary methodologies and libraries to support your custom development. Starting a new application Out of the box, ServiceNow provides many applications for facilitating business operations and other activities in an IT environment. But as you will often discover, the customer's expectations go above and beyond the out-of-the-box system applications. This is when you'll customize existing features and begin creating new applications. In these recipes, we will cover all of the aspects of application development within ServiceNow. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance. For example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to System Applications| Studio: 2. This will open a pop-up tab to the Application Studio. Since this is our first time here, it will ask us where we'd like to begin. Click Create Application: 3. This will bring up the Create Application wizard. Since most apps consist of a table with entries, we'll let ServiceNow do the heavy lifting. Next to Create custom application click Create: 4. This will bring up the Create Application form. Let's name our new app—SNow Cookbook Chapter 3. The remaining fields will autopopulate: 5. Next, click the Create Table toggle: 6. This will bring up the Table options, also auto-populated. I've selected Auto-number to create a database table sequence to number entries on the table. Feel free to adjust these options however you like. 7. Afterwards, click Create: 8. When the confirmation dialog comes up, click OK: Some processes will run, followed by a confirmation screen that our new app has been created! 9. Click Back to list to see your newly created app inside the Studio interface: 10. On the Load Application screen, click the SNow Cookbook Chapter 3 link for our new app: 11. The Studio interface organizes all of the application objects we've created into categories such as Data Model | Table, Access Control | Roles and Access Controls, and Navigation | Menus and Modules: 12. If you navigate back to your main instance, you can see our new app is already available on the Nav Bar. This lays the foundation for the recipes in the rest of this chapter: See also Creating applications: https://docs.servicenow.com/bundle/jakarta-application-d evelopment/page/build/applications/concept/c_CreatingApplications.html Adding new components to your application Within the ServiceNow Application Studio, you're able to keep all of the components associated with your application scope without the benefit of an Update Set or otherwise manually managing your code. For this recipe, we will practice adding a new component to our app. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role, and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to System Applications | Studio— then select your application: 2. Once you have your application open, click Create Application File in the upper-left corner: 3. This brings up a menu of a myriad of application objects that can be created within our app. For now, let's select Navigation | Module. Then click Create: 4. This will bring up the new Module form. Let's populate the following values: 1. Title: Create New Custom Record 2. Application Menu: Select the item that matches your app 5. Next, under the Link Type related list, populate the following values: 1. Link type: New Record 2. Table: Select the table that matches your app 6. Then click Submit. The Studio interface should show our new item: 7. If you go back to the main ServiceNow interface, you'll see our new module already available for use: See also Creating application files: https://docs.servicenow.com/bundle/jakarta-applicati on-development/page/build/applications/task/t_AddAnAppFileToAnApp.html Publishing a new application Before we get too far into fleshing out our new application, we might want to take some time to think about how we might make it available to other ServiceNow environments and the organizations that use them. For this recipe, we're going to publish our application to GitHub. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role, and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. Additionally, you will need a GitHub account with rights to write to an existing repository. (It's free!) How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then open Studio and select your app under development: 2. Once you've opened your app, navigate to Source Control | Link To Source Control in the header bar: 3. This will open up the Link To Source Control dialog. Populate it with the following values: 1. URL: The URL of your repository 2. User Name: Username with write access 3. Password: Password for above username 4. Commit Message: Relevant and meaningful information on what this commit is. DON'T BE THAT DEV!! 4. Then click Link To Source Control: A process dialog will run with a success message. Blue bars are good! Now, you will be able to commit and preserve your history within the Source Control feature of Studio: There's more... GitHub isn't your only option for source control and sharing your applications, another popular option is to utilize the ServiceNow store to either share or market your app to potential customers. For more information on joining the store, visit: https://docs.s ervicenow.com/bundle/jakarta-application-development/page/build/appl . ications/task/t_PublishAppsToTheServiceNowStore.html See also Application sharing: https://docs.servicenow.com/bundle/jakarta-application-dev elopment/page/build/applications/concept/c_SharingApplications.html Using the Team Development plugin The Team Development module is a feature for developers to automatically promote and pull changes between their environments. For instance, if you are assigned to a larger development team where multiple developers are working on one environment, the Team Development module helps these teams minimize the impact of their changes and reconcile changes quickly. Getting ready To use this recipe, you should have at least two active ServiceNow instances (Jakarta), valid credentials, and an admin role. If you have a code reviewer in your team, then the reviewer should be added to the Team Development Code Reviewers group or another group with the teamdev_code_reviewer role. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then navigate to Team Development | Team Dashboard: 2. Inside of the Welcome To Team Development frame, click Register a new instance: 3. This will open up the Remote Instance form. Populate the values as follows: 1. Name: Remote Instance 2. Type: Test 3. URL: URL to your second instance, for example, https://{instancename}.service-now.com 4. Username: Username with admin role 5. Password: Password for above username 6. Active: Checked 7. Short Description: Test Instance For Demo Purposes 4. Then click Test Connection: A dialog will appear indicating whether your Connection is OK. Then click Submit: With the relationship between the two instances created, you are now able to push updates from one instance to another. Changes made in either environment will be automatically detected by Team Development for easy reconciliation: See also Team Development: https://docs.servicenow.com/bundle/jakarta-application-deve lopment/page/build/team-development/concept/c_TeamDevelopment.html Getting into client scripting Client scripts are JavaScript code that are interpreted by the user's web browser. Client scripts can be used to put validation on a ServiceNow form and for customization of ServiceNow behavior, such as making any field read-only, mandatory, or hidden. While client scripts are very powerful and versatile, they should be considered a last resort as they add latency to the form loads and operations. Additionally, client-side JavaScript can be overridden, halted or otherwise manipulated on the client. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then open Studio and select your app under development: 2. Click on Create Application File: 3. From the Create Application File interface, select Client Development | Client Script. Then click Create: 4. If you're familiar with JavaScript, the types of client scripts might sound familiar. They are as follows: 1. : When a particular field is changed from list OnCellEdit view 2. : When a field's value is changed on a form or item OnChange view 3. OnLoad : When an item view is first loaded 4. OnSubmit : When a form is submitted, usually either from a submit or save action 5. For this recipe, let's do an OnLoad script. Populate the following values: 1. Name: Make Number Field Read Only 2. Table: Any Table in the app with a Number field. I'm using the table created in a previous recipe 3. UI Type: All 4. Type: onLoad 5. Script: Input the following code function onLoad() { g_form.setReadOnly('number',true); } 6. Then click on Submit: Now, when a user opens a new record for this table, the Number field will be read-only: There's more... You might have noticed the g_form object being referenced in the code block. This is a client side object/library that provides a wealth of useful methods and other calls you can make against the ServiceNow form view. Again, UI Policies and other proprietary platforms are more consistent and predictable, but client scripts give developers the ability to add some really interesting and powerful features. See also Client scripts: https://docs.servicenow.com/bundle/jakarta-servicenow-pla tform/page/script/client-scripts/concept/client-scripts.html g_form: https://docs.servicenow.com/bundle/jakarta-application-developme nt/page/app-store/dev_portal/API_reference/GlideForm/concept/c_GlideFormAP I.html Getting into server scripting While we've covered scripting and business logic on the client side, what's going on on the server side? ServiceNow provides several ways to implement business logic and shared services on the server itself. The most common of these is the business rule. Business rules are event-based activities that drive other actions based on the data being accessed or changed. Business rules have an additional benefit of running not just from form interfaces, but also whenever other events are triggered server side, such as scheduled jobs or API calls. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role, and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance. For example, https://{instancename}.service-now.com, then open Studio and select your app under development: 2. Click on Create Application File: 3. From the Create Application File interface, select Server Development | Business Rule. Then click Create: 4. In the new Business Rule form, populate the following values: 1. Name: Auto-Populate Due Date 2. Table: Any table in the app. I'm using the table created in a previous recipe 3. Active: Checked 4. Advanced: Checked So, wait a second. Do we have a Due Date field on our table? I don't! Before we proceed further, please ensure you have a suitable Date field on the table you're using. 5. Within Studio, highlight the table in question and then click New under Table columns: 6. Populate the following values in the Table Column form. Then click Submit: 1. Type: Date 2. Column Label: Due Date 3. Column Name: due_date (This should auto-populate) 7. Once you've confirmed you have a suitable column, go back to your Business Rule. Under the When To Run tab, populate the following: 1. When: After 2. Filter Conditions: Due Date is Empty 3. Insert: Checked 4. Update: Checked 8. We want to set the Due Date automatically to seven days from now if it's not currently populated; we're going to do this via some JavaScript. Under the Advanced tab, enter the following code: (function executeRule(current, previous /*null when async*/) { var now = new GlideDateTime(); now.addDaysLocalTime(7); current.due_date = now.getDisplayValue(); })(current, previous); 9. Then click Submit. Once you've saved your new Business Rule, any record you create without your Due Date field populated will add a value of that date plus seven days. 10. To test, create a new record without populating the field: Your new record, and any previous records, should autopopulate on creation or any subsequent update where it's not present: There's more... You might have noticed the GlideDateTime object being referenced in the code block. This is a server-side object that can be called as needed to instantiate a new Date object. You're welcome to use JavaScript (or even Java) methods in script blocks, but it's best to leverage the Glide libraries already available in the ServiceNow platform. See also Business rules: https://docs.servicenow.com/bundle/jakarta-servicenow-pl atform/page/script/business-rules/concept/c_BusinessRules.html GlideDateTime: https://docs.servicenow.com/bundle/jakarta-application -development/page/app-store/dev_portal/API_reference/glideDateTimeScoped/c oncept/c_GlideDateTimeScoped.html#ariaid-title29 Glide stack: https://docs.servicenow.com/bundle/jakarta-application-deve lopment/page/script/glide-server-apis/concept/c_GlideSystem.html Understanding development best practices – script includes To me, best practices is a loaded term. For me, the key to best practices in development is being present when making decisions and taking proper ownership of what you're doing in any code base. And while ServiceNow is an environment designed for low or no-code developers, we still owe it to ourselves to know how changes we make will impact the user experience and avoid painting, ourselves into corners. For the client-side and server-side recipes, we implemented a client script and a business rule. Each of these do separate things in different ways in our app. But, what happens when we start to repeat ourselves or want to use the same bit of code elsewhere in our environment? The process for upgrading, consolidating, and removing redundancy in code is called refactoring. One resource we can use for refactoring in ServiceNow is called the Script Include. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role, and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then open Studio and select your app under development: 2. Click on Create Application File: 3. From the Create Application File interface, select Server Development | Script Include and click Create: 4. In the Script Include form, populate the following values: 1. Name: Chapter3Lib 2. Client callable: Checked 3. Description: Shared library for Chapter 3 App 4. Script: Input the following code var Chapter3Lib = Class.create(); Chapter3Lib.prototype = Object.extendsObject(global.AbstractAjaxProcessor, { type: 'Chapter3Lib', calculateDueDate: function(){ var now = new GlideDateTime(); now.addDaysLocalTime(7); return now; }, }); 5. Then click on Submit: Now that we have our shared code, we need to add new code to call it or refactor existing code that already does the same thing. For this, let's edit the business rule we created in our previous recipe. 6. Update the Script value to the following: (function executeRule(current, previous /*null when async*/) { var c3lib = new Chapter3Lib(); current.due_date = c3lib.calculateDueDate(); })(current, previous); And then click on Update: 7. Now let's create a new record to see if our code is working: Looks like it's working! There's more... When refactoring, it's most important to be mentally present in what you're trying to accomplish. For instance, we could take the use of our library even further and have a client script call it from the user session itself, thereby setting the date before it's even saved. Additionally, we could have the library call a table where various due dates are stored for different types of items, thereby eliminating the hard coding of static values or magic numbers. See also Script includes: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/p age/script/server-scripting/concept/c_ScriptIncludes.html Understanding web services Since ServiceNow is a web-hosted platform, web services naturally come with the territory. You'll likely have scenarios where you'll want to pull information from external sources, such as user data. Or, you'll have thirdparty platforms that want to access your environment to either create work product or check status on existing items. As we covered in Chapter 1, Getting Started with ServiceNow, every table in ServiceNow has a default REST API. Instead of just retrieving records from our custom table, let's look at creating a new record. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role, and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then navigate to System Web Services | REST | REST API Explorer: 2. Inside of the REST API Explorer interface, click on Create a record (POST) and then choose a table from your app with which to create a new record: 3. Scroll down to the Builder tab near the bottom of the form. From here, you can add values to populate on the form. I've added a couple of string fields for demonstration purposes. 4. To populate your values, click on Add a field then select the field name in the dropdown and add the value in the adjoining field. 5. Once you're ready to submit, click on Send: A dialog will appear asking you to confirm, click on OK: 6. You should receive a confirmation of a successful creation and a response body in the interface: If you look at the list view for your table, the new record with the submitted values should be available. There's more... Another useful feature of the REST API Explorer is that it will give you code samples for various platforms. This is helpful for when third-party developers want to integrate with your system. Here's an example of the JavaScript code that would trigger a POST against our API. var requestBody = "{\"title\":\"Request for parts\",\"request_description\":\"I need a new flux diode\"}"; var client=new XMLHttpRequest(); client.open("post","https://dev41882.servicenow.com/api/now/table/x_70280_snow_cookb_snow_cookbook_chapter_3_table"); client.setRequestHeader('Accept','application/json'); client.setRequestHeader('Content-Type','application/json'); //Eg. UserName="admin", Password="admin" for this code sample. client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin')); client.onreadystatechange = function() { if(this.readyState == this.DONE) { document.getElementById("response").innerHTML=this.status + this.response; } }; client.send(requestBody); See also REST API Explorer: https://docs.servicenow.com/bundle/jakarta-application-dev elopment/page/integrate/inbound-rest/concept/c_RESTAPIExplorer.html Implementing automated testing Testing is much like documentation. Everyone wants it but nobody wants to spend any time on it. Beginning with the Istanbul release, ServiceNow has implemented an easy-to-use module for testing called the Automated Test Framework. Let's take a look. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, an admin role, and an application already created in Studio. If you've provisioned an app in the first recipe of this chapter, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then navigate to Automated Test Framework | Administration | Properties. 2. Obviously, the first thing we need to do is turn on the testing module. Select Yes for the Enable test/test suite execution checkbox. Then click on Save: 3. Next, let's create a test to validate some UI behavior we implemented in a previous recipe. Our customers paid our developers to make the Number field read-only on our table. We want to ensure that this behavior stays in place, or at least detect it if it fails at a later time (regression detection). 4. Navigate to Automated Test Framework | Tests. Then click on New: 5. In the new record form, let's name our test something meaningful. Call it Number field is read only then click on Save: 6. Now that we have our test created, it's time to make it do useful things. Click Add Test Step in the Test Steps tab: 7. In order to check if the Number field is behaving the way we want, we must first open the form. Navigate to Form | Open a New Form then click Next: 8. In the Add Test Step screen, select the relevant Table from your app in development. Then click on Submit: 9. Our first step will open up a new record form. Next, we'll add a test step to test the read-only behavior of the field. Click Add Test Step again in the Test Steps tab: 10. In the Add Test Step form, select Form | Field State Validation then click Next: 11. In this Add Test Step form, we'll want to add the Number field to the Read only section. Use the slush bucket in that section to move the Number field over to Selected. Then click on Submit: 12. It's a bit minimalist, but now we have a working test. Let's click Run Test to see it run: 13. Since this is a UI Test, ServiceNow needs a free browser window to borrow for pulling up the form and testing. Click Run Test: This will open up a test runner window and your tests will execute. It will look something like the following screenshot: And if you navigate back to your test entry, you'll see the results of the test. Again, blue bars are good! 14. If you click Go to Result, you'll see a log of the test steps and results. The framework will even keep screenshots of UI steps to assist with troubleshooting or general use. This can be kept for a set amount of time, or indefinitely if desired: There's more... This recipe should give you a small idea of what's possible in ATF. I cannot understate the value of building tests as you go. They are simply the closest thing you're going to have to a transcript of customer requirements when you have a reported issue in your platform or introduce a bug or other error during subsequent development. Don't neglect this dimension of software development! See also Automated Test Framework: https://docs.servicenow.com/bundle/jakarta-servi cenow-platform/page/administer/auto-test-framework/concept/atf-overview.html Configuring Alerts and Notifications In this chapter, we will cover the following recipes: Setting up email notifications for users Working with email templates Getting into notification scripts Understanding email watermarking Email troubleshooting Configuring delegates Introduction Communication and proactive notifications are essential to any IT Service Management application. Therefore, ServiceNow has a core function to send or receive notifications. Generally, they are email based, but they can also take the form of SMS messages or other push notifications to mobile devices. Outbound notifications are generally based on events and activities inside the environment. Inbound messages can be processed into new work products, such as an incident or request, or an update to an existing item. Setting up email notifications for users Microsoft Exchange is widely used by many individuals and corporate houses for email communication. This recipe will show you the basic configuration to enable incoming or outgoing emails for ServiceNow. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com; then, on the left-hand side in the search box, navigate to System Mailboxes | Administration | Email Properties. 2. Click the checkboxes for Email sending enabled and Email receiving enabled: 3. Click Save. Your email functionality is now enabled! Now what? 4. Let's configure a custom notification for an incident. Navigate to System Notification | Email | Notifications and click New on the Notifications List View. 5. We want a custom notification to fire whenever someone creates a . Populate the following values in the Priority 1 Incident (Critical) header: 1. Name: Priority 1 Incident (Critical) 2. Table: Incident[incident] 3. Active: Checked 6. Then, in the When to send tab, populate the following: 1. Inserted: Checked 2. Conditions: Priority is 1-Critical 7. For the Who Will Receive tab, just click the Add Me button to add System Administrator to the recipient. 8. Lastly, for the What it will contain tab, you'll populate some email content about the Priority then click Submit. 1. Subject: PRIORITY . Use the following, and 1 Incident ONE! - ${number} 2. Message HTML: Input the following code: Priority 1 Incident Number: ${number} has been assigned to Assignment group: ${assignment_group}. Short description: ${short_description} Description: ${description} Created by: ${sys_created_by} The form should look as follow prior to saving: 9. Now let's create a Priority 1 incident and see if the notification fires. Navigate to Incident | Create New and create an incident with Priority 1. 10. Our new notification should automatically fire to the intended recipients (ourselves) and will be visible in both the incident and under System Logs | Emails: See also Email setup: https://docs.servicenow.com/bundle/jakarta-servicenow-plat form/page/administer/reference-pages/concept/c_EmailConfiguration.html Notifications: https://docs.servicenow.com/bundle/jakarta-servicenow-pla tform/page/administer/notification/reference/notifications.html Working with email templates An email template is a reusable component that may be used with more than one notification to keep a consistent look and feel to similar notifications. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com; then, on the left-hand side in the search box, navigate to System Policy | Email | Templates. Let's create a new Email Template by clicking New. 2. In the previous recipe, we created a custom notification for Priority 1 Incidents. Let's say we want to reuse the same format for multiple notifications. We could create a template by populating the following values and then clicking Submit: 1. Name: Priority 1 Incident 2. Table: Incident[incident] 3. Subject: PRIORITY ONE! - ${number} 4. Message HTML: Input the following code: Priority 1 Incident Number: ${number} has been assigned to Assignment group: ${assignment_group}. Short description: ${short_description} Description: ${description} Created by: ${sys_created_by} The form should look as follows prior to saving: 3. Now that you've created a template, you can either create a new notification or refactor an existing one by modifying the Email template field in the notification. This saves a great deal of manual curation of individual notifications in favor of using a shared code base: See also Email templates: https://docs.servicenow.com/bundle/jakarta-servicenow-platform /page/administer/notification/concept/c_EmailTemplates.html Getting into notification scripts Sometimes, you're going to need to retrieve related information that isn't present or reachable from the fields on the current table. In cases like these, the notifications module supports scripting to incorporate deeper or more complex logic. Additionally, this is another way to incorporate shared code into multiple notifications. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then, on the left-hand side in the search box, navigate to System Notification | Email | Notification Email Scripts. 2. Leadership has decided that P1 incident responders need to understand which assets a P1 caller is responsible for when they receive an incident. We need to build a script to incorporate a lookup on the asset table and append the caller's assets to the email. 3. In the new Email Script form, populate the following values, and then click Submit: 1. Name: incident_assigned_assets 2. Newlines to HTML: Checked 3. Script: Input the following code: (function runMailScript(current, template, email, email_action, event) { template.print('User : '+ current.caller_id.name +' is responsible for the following assets'); template.print('<p>'); var lookup = new GlideRecord('alm_hardware'); lookup.addQuery('assigned_to',current.caller_id); lookup.query(); while (lookup.next()){ template.print(lookup.display_name); template.print('<br>'); } template.print('</p>'); })(current, template, email, email_action, event); 4. Now we're going to modify our P1 notification to incorporate our script. (Or you can use any other notification for your script.) 5. Next, navigate to System Notification | Email | Notifications and select any of your notifications from the list view. 6. In the What it will contain tab, append ${mail_script:incident_assigned_assets} to the Message HTML field. 7. Then, from the Notification form, click the Preview Notification. You should see something like the following: See also Email scripts: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/pag e/script/server-scripting/concept/c_ScriptingForEmailNotifications.html Understanding email watermarking Each outbound notification has a watermark appended. This mark consists of a database sequence ID (MSG***) as well as a random suffix of an underscore and 20 random characters. They are included to help authenticate messages from your environment and cut down on spoofing or man-in-the-middle type attacks. Beginning with the Jakarta release, watermarks can be customized for your environment or omitted altogether. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com; then, on the left-hand side in the search box, navigate to System Definition | Number Maintenance and open up the MSG record. 2. Change the Prefix value to something suitable to your environment, in my example I'll use BLUESUN, and then click Update: 3. After you've updated your email watermark sequence prefix, you can test the results by generating a notification and looking at the email. I'll create a new Priority 1 incident to test: As you can see in the email logs, our new prefix is now the default for all email watermarks. See also Email watermarking: https://docs.servicenow.com/bundle/jakarta-servicenow-pla tform/page/administer/notification/concept/c_WorkingWithWatermarks.html Email troubleshooting During your day-to-day support tasks, you're certain to come across reports of missing or excessive email traffic. Knowing how to configure global properties and review the email logs are important pieces of knowledge. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com; then, on the left-hand side in the search box, navigate to System Properties | Email Properties. 2. Important configuration notes: 1. Use the Email Sending Enabled and Email Receiving Enabled checkboxes to globally turn off either function. This is most important for your development and testing environments, but it also could be important in the event of an unexpected DDoS or other inbound attacks. 2. Use the Ignore email from these senders field to selectively block individual aliases or senders. 3. Use the Ignore email when subject starts with.. field to selectively block individual subject types. This can be used to block out-of-office traffic or turn off Forward or Reply All traffic. 3. To find the logs, navigate to System Logs | Email. This list view will keep a complete record of all inbound and outbound email traffic for troubleshooting purposes. Please ensure you're using appropriate business logic to keep the log form cleaned up and manageable. Check out the email retention plugin if you'd rather not manage the email archive manually. See also Email setup: https://docs.servicenow.com/bundle/jakarta-servicenow-plat form/page/administer/reference-pages/concept/c_EmailConfiguration.html Email retention: https://docs.servicenow.com/bundle/jakarta-servicenowplatform/page/administer/notification/concept/email-retention.html Configuring delegates Now that we've configured email traffic and built custom notifications for our user community, how do they let us know when they're out of the office or otherwise unavailable? In a perfect world, they'd set up a delegate to receive their emails. Out of the box, it would be up to your support staff to set this up. Let's configure ServiceNow so that users can do this on their own. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com; then, on the left-hand side in the search box, navigate to System Security | Users and Groups | Users. Select any User record so that we can access the context menu. 2. Right-click on the header bar and select Configure | Related Lists from the context menu: 3. Add the Delegate | User related list through the slush-bucket and click Save. You'll likely want to do this in the Self-Service view to ensure your non-ITIL users can see it with minimal effort: 4. Now let's impersonate a user. I'm using Abel Tuter in this example. From the user context menu, select Profile: 5. You should be able to see the Delegates related list on the user form. Click New to create a new delegate: From this form, you can choose a new delegate, which notification traffic they will receive, and when this should begin and end. I can't stress how useful this simple step is for users and how many cycles it will save your ServiceNow administrators. Teach this early and often! See also Service delegation: https://docs.servicenow.com/bundle/jakarta-servicenow-platfo rm/page/use/employee-self-service/concept/c_ServiceDelegation.html Building and Configuring Reports In this chapter, we will cover the following recipes: How to view and run reports Creating custom reports Getting into reporting templates How to schedule a report Creating a dashboard Working with the database view for reporting Introduction Reports are an essential part of any enterprise application. One of your most common requests from leadership will be to create and customize reporting. ServiceNow provides a dedicated reporting application, which can be accessible by admins, ITIL users, and several custom roles associated with the reporting app. In this chapter, you will see how you can view and create reports, create a shared code base of reporting elements, automate reporting tasks, and create visualizations for reporting data. How to view and run reports ServiceNow can provide reports in Excel, PDF, and certain image formats. In this recipe, you will see how to view and run already existing reports in the ServiceNow environment. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Reports | View/Run, which will bring up a list view of out-of-the-box reports that are installed by default: 2. From here, you can sort reports by title or table. There is also a global search window where you can search for any report by various criteria. Let's type Incident there. This will bring up a typeahead results list. If you click Enter inside of the search box, the main report list will filter based on your criteria: 3. Let's select the Incident Trend By Priority report: This brings up a visualization of the report and gives you a breadcrumb trail that identifies what the report is based on. (Closed in the last three months and priority isn't empty.) 4. Let's change the visualization under Type in the report sidebar. I'm a fan of donuts, but you're welcome to try any visualization you like. Click Next once you've decided: This will bring up your new visualization. The breadcrumb hasn't changed, but the manner in which it displays has: I'm not a design person, but I've learned from smarter people that the impact of design and visualization to convey meaning to leadership cannot be overstated. While it seems like a couple of simple toggles, reporting is one of the core value-adds of the platform. See also View reports: https://docs.servicenow.com/bundle/jakarta-performance-analytics-a nd-reporting/page/use/reporting/reference/r_ViewTheReportsList.html Creating custom reports By default, ServiceNow provides the View/Run module to view the existing report or create a new report. In this recipe, you will learn how to create new reports within the ServiceNow environment. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then, on the left-hand side in the search box, navigate to Reports | Create New. 2. Beginning with the Data tab, populate the following values, and then click Next: 1. Report name: Incident Chapter 5 2. Source type: Table 3. Table: Incident[incident] This will bring up the Type tab. If you completed the previous recipe, you'll remember that this is where we choose a visual style for our report. Let's do a pie chart this time. Click Next: 3. Right now, we're scanning the entire incident table to get our results. We want to narrow this down a bit. Populate the Configure tab with the following values: 1. Group by: Priority 2. Aggregation: Sum + Age In Days This will display all of the incidents we query grouped by priority. Then a total number of days the groups of incidents have been open. 4. We're missing something, though. Leadership wants a live report of open tickets and doesn't want to include the age of every incident on the table. We need to filter our results. Click the filter icon to create a qualification for our query. 5. Once you click on filter icon, it will open up the CONDITIONS interface. Let's ensure we're only getting active incidents by setting a qualification of Active is true: 6. When you've finished adding the qualification, click Run to see the results. You may need to create some open incidents if you're working on a personal dev instance. Once you've tested your report, click Save to save your report to the instance. 7. One more thing: you'll want to ensure reports you create are available to groups or individuals that want to use it. Click the Share button to make it available to others. 8. From the Sharing settings dialog, you can choose to make the report available to everyone, or a selection of groups and/or users: In making their decision to invest in ServiceNow, your leadership has likely anticipated realizing value with data and measures to assist with making organizational improvements. Make sure you spend a little time in this space to respond to requests. See also Creating a report: https://docs.servicenow.com/bundle/jakarta-performance-analyt ics-and-reporting/page/use/reporting/task/t_CreateYourOwnReport.html Getting into reporting templates As mentioned before, styling is an important part of the visualization of reports. ServiceNow can generate reports from virtually every data source in the platform, but often, you'll want to include some canned styling to every report. One way to approach this is with header footer templates. These are available for PDF-formatted reports only, but can be useful when you want to schedule a series of reports and include some basic styling with each one. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then, on the left-hand side in the search box, navigate to Reports | Header Footer Templates, then click the New button. You can name the template whatever you like. For this example, I'm naming mine Chapter 5 Template. 2. For the Header Configuration or Footer Configuration tab, you can include the following values for the left, middle, and right of the header, or leave them empty: 1. Page X: Displays the current page number 2. Page X of Y: Current page number of total pages 3. Report Title: Name of the report 4. Run By: Name of the individual who ran the report 5. Run Date and Time: Date and time of the report 6. User Specified Text: Custom text 7. Image: Image file useful for branding I'm going to include the default values in my template. For the Left header content, I'll include the Report Title, and for Right header content, I'll include Page X: And for the Footer Configuration, in Left footer content, I'll include the Run By value and for Right footer content, I'll include Run Date and Time. Then, click Submit: 3. Now that we have a template available, let's apply it to a report. You can use anything in the report library. For my example, I'm going to use the Incident Chapter 5 report created in a previous recipe. Applying templates is only available in the Classic UI in Jakarta. You'll want to click the Switch to Classic UI link before following these next steps. 4. With this report open, click on the down arrow next to the Save button and select Export settings: 5. This will bring up a dialog where we can choose our newly created template. Select it from the lookup field and click Close: 6. Next, select the Export to PDF option from the down-arrow menu. Once the export is complete, it will be available for download: You'll be prompted to save the PDF locally and open it. The header and footer information you've selected in your template will be displayed in the report data. See also Report templates: https://docs.servicenow.com/bundle/jakarta-performance-analyt ics-and-reporting/page/use/reporting/concept/c_PDFPageHeaderFooterTemplates.html How to schedule a report So, we've covered the basics of how to build a report. What about making the outputs available to a wider audience? It's foreseeable that your leadership and other interested parties won't be day-to-day users of ServiceNow, but they still need regular updates on what's going on in your IT organization. Let's take a look at how that's done. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then, on the left-hand side in the search box, navigate to Reports | Scheduled Reports. 2. Once you're on the list view, click the New button, populate the following values, and then click Submit: 1. Name: Chapter . 5 Weekly 2. Report: Incident Chapter 5—you can use whatever report you like. For this example, I'm using the report from our previous recipe. 3. Users: Here is where you can designate individual users. Recipients need to be on your Users table but don't need to have roles within ServiceNow. 4. Groups: Select a group of users who need to receive this report. This is useful for managing reports to logical groups of users, such as department heads or other IT leaders. 5. Email Addresses: You can designate plain text email recipients for your reports as well. Ensure you are not violating any company policies or compliance expectations when sending ITSM data outside your organization! 1. Run: Weekly 2. Day: Monday 3. Time: 7:00:00 4. Subject: Chapter 5 Weekly 5. Introductory message: This will contain the body of your email. It's useful to include some explanatory text here to describe the contents of the report and the intent. 6. Type: PDF-landscape: This is where you'll choose the format for the actual report data. PDF will include any template you've assigned to that particular report, or you can choose a spreadsheet or image output. 3. If you'd like to test your report output, open the newly created report and click the Execute Now button. Your recipients should receive the output through email. Remember to test! See also Schedule a report: https://docs.servicenow.com/bundle/jakarta-servicenow-platfor m/page/administer/reference-pages/task/t_ScheduleAReport.html Creating a dashboard Sometimes an email attachment isn't sufficient for sharing and visualizing report data. In this recipe, we will see how to create a dashboard. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then, on the left-hand side in the search box, navigate to Homepage Admin | Pages. Once you're at the list view, click the New button. 2. In the new page record, populate the following values, and then click Submit: 1. Title: You can choose anything you like. For this example, I'll use Chapter 5 Dashboard. 2. Selectable: True—this is very important, as it's what makes your new home page selectable. 3. User: This is where you'll designate an owner for the new home page. For now, I'll populate the System Administrator account. 4. Write roles and Read roles : Here's where you'll designate who can make changes to your new home page and who is allowed to see it. For now, I'll add the itil role under Read roles. 3. Now that we have our new home page in place, we need to make it available as a dashboard. Navigate to My Home and click the Create dashboard version button. 4. When the create dialog pops up, leave Create new dashboard selected and click Create: We're kind of taking the scenic route by creating a dashboard from a home page. If you'd rather skip the above steps and create a dashboard directly, you can navigate to Self-Service | Dashboards and click the New button. 5. Now that we have our dashboard created, let's add a report to it. Click the + button in the upper-right and select Reports. For my example, I'll be using the Incident Chapter 5 report we created in a previous recipe: 6. Click the Add button. 7. Next, we'll want to ensure our new dashboard is shared with the correct groups. Click the sharing button in the upper-right corner. Then add the itil role to this dashboard: 8. Click the Invite button. 9. Now, to test if those with the itil role can view the dashboard, let's impersonate an itil user. In this case, I'll use Abel Tuter. 10. Once you've impersonated a user, navigate to Self-Service | Dashboards and confirm that our dashboard is selected: You can repeat this process as needed to make reporting data available to users directly in the Self-Service module. See also Administering dashboards: https://docs.servicenow.com/bundle/jakarta-perform ance-analytics-and-reporting/page/use/dashboards/concept/c_DashboardAdministration. html Working with the database view for reporting ServiceNow provides system tables in which the data is stored and grants you the ability to create custom tables as needed. However, it's foreseeable that you'll receive requests for reporting that include results from multiple tables. In this case, you'd define a database view to assist with this request. In this recipe, you will learn to create a database view. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then, on the left-hand side in the search box, navigate to System Definition | Database Views. Then click the New button. 2. You can give any new view name you like. Ensure that there are no spaces in the name. For this example, I'm using u_chapter_5_join. Then click Submit. 3. Now we need to decide which tables we want to join. Let's say our leadership has requested a report of all incidents related to a problem. We'll include definitions for each of these tables, as well as a logical prefix for each, to identify similarly named variables from each table. 4. Under View Tables, click the New button. Populate the following values to include the Incident table and then click Submit: 1. Table: Incident[incident] 2. Variable prefix: inc 3. Where clause: inc_problem_id = pro_sys_id—this value is relating the problem field on the incident form to the sys_id on the problem record 5. Repeat this process by adding another View Table with the following values, and click Submit: 1. Table: Problem[problem] 2. Variable prefix: pro 6. Now, back at the Database View, click the Try It related link to see the results of your view definition. 7. This will pull up a list view of all the rows returned by our join, returning the first few columns alphabetically. You can refine the column definition by right-clicking any column header and clicking Configure | List Layout. The column slush-bucket will have the prefixes we've defined in the view. Include the Number field from each table to help the layout make more sense: 8. Click Save when you're done defining the view. This should bring up your list view with a more user-friendly definition of the incidents and problems being returned: You can refine and further qualify your view definition and the results list as needed. This is very useful for providing just enough information to users and integration providers, rather than forcing them to sort things out from the base database schema. See also Database views: https://docs.servicenow.com/bundle/jakarta-performance-analytic s-and-reporting/page/use/reporting/task/t_CreateADatabaseView.html Creating and Configuring Workflow Activities In this chapter, we will be covering the following recipes: Setting up workflow conditions Setting up approval activities Adding a task activity Adding notifications Subflows – triggering a workflow from another workflow Using timer activities How to use workflow utilities Introduction One of the most prominent comparative advantages of ServiceNow is its ability to manage the life cycle of a piece of work product. Often this work product is referred to as tickets. But in the ServiceNow world, they're generally referred to as tasks. As has been mentioned in previous chapters, the Task table is the base object of everything in the ITSM module. This table can readily be extended to new types of work which can be given their own rules and life cycle. The life cycle of this work is called a workflow. We touched on these in Chapter 1, Getting Started with ServiceNow. Here we'll be taking a deeper dive. Setting up workflow conditions In this recipe, we will demonstrate how to set the conditions for when a workflow is triggered. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. 2. The Workflow Editor is a proprietary interface where you manage workflows. Each workflow has a set of properties where global settings are managed and a graphical interface that visualizes the entire workflow from Begin to End. 3. To create a new workflow, click the + icon in the upper-right corner: This will bring up the New Workflow dialog where we can choose which table the workflow maps to and when it should bind to a task on that table. 4. Populate the following values: 1. Name: Chapter 6 Workflow – Priority 1 2. Table: Incident 5. Under the Conditions tab, we'll decide when the workflow should trigger. Populate the following and then click Submit: 1. If Condition Matches: Run the workflow always 2. Condition: Priority is 1 - Critical Your workflow is now created and is configured to trigger for all Priority 1 incidents. You should now see the graphical interface with the Begin and End steps: One thing you'll notice is the Checked out by me message next to your workflow title. When a workflow is checked out, it means that you have it locked for editing from everyone but yourself. Also, any edits you've made so far will only trigger when you create an item on the table with the matching conditions. This allows for easy testing and troubleshooting, without impacting other people working in the same system. See also Create a workflow: https://docs.servicenow.com/bundle/jakarta-servicenow-platf orm/page/administer/workflow-administration/task/t_CreateAWorkflow.html Setting up approval activities One common activity in workflows is the approval. You can configure an approval activity to trigger between any of the steps in a workflow. The approval can request responses from one or more users, and even one or more groups on your platform. Let's add an approval to our workflow. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. I'm going to open the workflow created in the first recipe of this chapter, but you're welcome to open any other workflow or create your own. 2. Select your workflow from the Workflows tab on the right sidebar. This should bring it up on the drawing canvas: 3. If your workflow is not checked out, use the hamburger icon in the upper-left corner to check it out: Just for demonstration purposes, we're going to add an Approval step for Abel Tuter to kick off our workflow. We will want the workflow to continue if he approves and end if he rejects. 4. From the Core tab on the right sidebar, click and drag the Approval – User activity onto your canvas. It can be found under Core Activities | Approvals: This will bring up the Workflow Activity interface. Under Approvers – Users, click the lock icon to open the user lookup and find Abel Tuter and click Submit. This will bring our approval activity on the canvas: 5. Next, we will delete the connecting arrow between the Begin and End steps. You can do this by highlighting the connection and clicking your Delete or Backspace key. 6. You can drag a new connection from the outcomes of the various steps in each activity. For this example, let's connect the Begin step to our newly created Approval – User activity: 7. Then, let's connect the Rejected outcome to the End activity. This will halt the workflow entirely if the approver responds with a rejection: For now, we won't add anything in the case of approved. But now, the approval request will be sent with items mapped to our workflow and will end immediately, if the approval is rejected. See also Approval actions: https://docs.servicenow.com/bundle/jakarta-servicenow-platfor m/page/administer/workflow-activities/reference/r_ApprovalAction.html Adding a task activity One very common workflow modification will be to add a task. In this recipe, we'll be covering the basics. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. I'm going to open the workflow created in the first recipe of this chapter, but you're welcome to open any other workflow or create your own. 2. Select your workflow from the Workflows tab on the right sidebar. This should bring it up on the drawing canvas: 3. If your workflow is not checked out, use the hamburger icon in the upper-left corner to check it out: In the previous recipe, we added an Approval step to our workflow and instructed the workflow to end if the approval is rejected. But what about if it's approved? In this case, we're going to assign a task for a review of our incident. 4. From the Core tab on the right-hand sidebar, navigate to Tasks | Create Task then click and drag that to your canvas. This will bring up the Create Task dialog: 5. Let's populate the following values and click Submit: 1. Name: Create Review Task 2. Task type: Task 3. Wait for completion: Unchecked—this is where you could have the workflow wait until the task is completed; in this case, we're going to allow the task to run in parallel to other activities in the workflow 4. Fulfillment Group: IT Fulfillers—you can select any group you wish; I'm using the group we created back in chapter 1 5. Short Description: Review Priority 1 incident 6. Instructions: Put some appropriate instructions for fulfillment of the task here 6. Afterwards, click and drag some connections between your task into the flow. For my example, I'm having the task trigger in case of an approval and then proceed to the End step: This is a very minimalist example of a task activity in a workflow. You can launch parallel task flows and require that they all be completed before ending the workflow, each of which with multiple approval steps and other activities. Please do be mindful of naming your tasks meaningfully and closing out each individual thread you create. See also Workflow tasks: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/ page/administer/workflow-activities/reference/r_CreateTask.html Adding notifications In Chapter 4, Configuring Alerts and Notifications, we covered alerts and notifications. Within workflows, you can also create ad hoc notifications or trigger existing notifications from those configured on your platform. In this recipe, we'll cover how to create an ad hoc notification. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. I'm going to open the workflow created in the first recipe of this chapter, but you're welcome to open any other workflow or create your own. 2. Select your workflow from the Workflows tab on the right sidebar. This should bring it up on the drawing canvas: 3. If your workflow is not checked out, use the hamburger icon in the upper-left corner to check it out: 4. In the previous recipes, we've built a workflow with an Approval step and a task step. But let's say that we want either a shift lead or other individual to be aware in real time when a Priority 1 incident is logged. For this purpose, we'll create an ad hoc notification to an individual with the appropriate information. 5. From the Core tab on the right-hand sidebar, navigate to Core Activities | Notifications | Notification then click and drag that to your canvas. This will bring up the New Activity: Notification dialog: 6. Let's populate the following values and click Submit: 1. Name: Notify Shift Lead of Priority 1 Incident 2. To: You can add as many users to this field as you like. Additionally, plaintext email addresses are supported 3. To (groups): You can add as many groups as you like as well; for a notification like this, it might be appropriate to include an Incident Managers group 4. Subject: Priority 1 Incident Has Been Logged! 5. Message: Input the following code: Priority 1 Incident Number: ${number} was logged at ${sys_created_on} 7. For the purposes of this workflow, we don't want this notification to be dependent on any approvals or the completion of other tasks. Additionally, we want it to take place immediately when the workflow conditions are met. Therefore, we will connect it to our workflow immediately after the Begin step, followed by the first approval: You can modify the audience for each notification within the notification step. Most of the time, it's better to future proof your notifications by mapping them to logical groups rather than individuals. This way, if someone leaves the company or changes roles, the audience will be automatically updated by the group memberships rather than being hardcoded in the workflow. See also Create workflow notification: https://docs.servicenow.com/bundle/jakarta-serv icenow-platform/page/administer/workflow-activities/reference/r_NotificationActivit y.html Subflows – triggering a workflow from another workflow Often you'll have activities that are common between workflows. Just like any other part of your code base, workflows can benefit from a refactoring process. When these common processes are identified, they can be fashioned into their own workflow. In this recipe, we'll cover adding a workflow within another workflow. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. I'm going to open the workflow created in the first recipe of this chapter, but you're welcome to open any other workflow or create your own. 2. Select your workflow from the Workflows tab on the right sidebar. This should bring it up on the drawing canvas: 3. If your workflow is not checked out, use the hamburger icon in the upper-left corner to check it out: 4. For use in this example, I'm going to replace the Review Task step with its own subprocess. To do this, I'll need to create a new workflow with the following values: 1. Name: Chapter 6 Subflow 2. Table: Global—this value can be used in table selection when the subflow doesn't apply to any particular table 3. If condition matches: None—this is the value we use when we want the workflow to only run when explicitly called Afterwards, we'll Publish our new workflow. I'm not actually putting in the Create Task step for this example. However, you can have your subflow include as many steps or processes as you wish. Once it is complete, the parent workflow will resume. 5. Now, to bring in our subflow, I'm going to click and drag it into the canvas for our parent workflow: This will bring up the New Activity dialog. You can just click Submit to accept the default values. 6. With the new Workflow Activity on the canvas, we can remove the replaced activities and connect the new one: You can nest these as deep as you like within the workflow. Over time, it's likely that you will grow a library of shared subflows that are reused in several processes. By keeping your workflows centralized in this manner, you can improve consistency in platform behavior and save a great deal of effort in updating a large number of objects with the same changes. See also Subflows: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/adm inister/workflow-activities/reference/workflows-as-subflows_1.html Using timer activities Often you'll want a workflow to either wait for a certain amount of time before proceeding, or to check for updates or status periodically to check for a status elsewhere for the same reason. In this recipe, we'll add a simple wait timer to a workflow. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. I'm going to open the workflow created in the first recipe of this chapter, but you're welcome to open any other workflow or create your own. 2. Select your workflow from the Workflows tab on the right sidebar. This should bring it up on the drawing canvas: 3. If your workflow is not checked out, use the hamburger icon in the upper-left corner to check it out: 4. Leadership has decided that we're going to wait 24 hours before launching a review of Priority 1 incidents. To add a Timer, click and drag the activity in the right sidebar under Timers | Timer. This will bring up the New Activity dialog. 5. Let's populate it with the following values and click Submit: 1. Name: Priority 1 Timer 2. Timer based on: A user specified duration 3. Duration: Days 1 6. Once you've added the activity, let's wire it up between the Approval step and our subflow created in the previous recipe: Obviously, this is a simple example. However, you're bound to encounter examples where process managers want workflows to wait for a set amount of time before ending or proceeding to additional steps. This is one of the most straightforward ways to accomplish this. See also Timer activities: https://docs.servicenow.com/bundle/jakarta-servicenow-platform/ page/administer/workflow-activities/reference/r_Timer.html How to use workflow utilities Utilities is a section in the workflow sidebar that covers activities like branching and joining multiple paths, setting values on the entry bound to the workflow, making web services calls, and running ad hoc scripts. In this recipe, we're going to update the attached record with some annotations, once this workflow is complete. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Workflow | Workflow Editor. I'm going to open the workflow created in the first recipe of this chapter, but you're welcome to open any other workflow or create your own. 2. Select your workflow from the Workflows tab on the right sidebar. This should bring it up on the drawing canvas: 3. If your workflow is not checked out, use the hamburger icon in the upper-left corner to check it out: 4. While our Priority 1 incident is launching a review process, we need to tell the incident when that subflow is actually complete. We could extend the Incident table with a checkbox or other column to hold this information. 5. For now, we've decided that updating the Work Notes field is sufficient. We can accomplish this with a Set Values activity. 6. Click and drag the Set Values activity from the Utilities section of the sidebar. This brings up the New Activity dialog: 7. We will populate the following values: 1. Name: Update Priority 1 Incident 2. Set these values: Work Notes – Priority 1 Incident Review Complete 8. Once you've added this activity, let's wire it up between our subflow and End steps: Now, there will be a record in the parent incident that this workflow completed the review subflow. This process could be further refined with some business rules on the Incident table to check for the review completion or by annotating the parent incident with the review task number. See also Workflow utilities: https://docs.servicenow.com/bundle/jakarta-servicenow-platfo rm/page/administer/workflow-activities/concept/c_UtilityActivities.html Auditing and Diagnosing ServiceNow In this chapter, we will be covering the following recipes: Understanding auditing in ServiceNow Working with auditing tables Understanding ServiceNow upgrades Working with system logs Session debugging Background scripts Introduction As your implementation of ServiceNow grows, it's inevitable that you'll face the need not only to get accurate queries on existing data, but also a view of the change history of individual records. Based on the outcome of these reviews, you might discover bugs or other unanticipated behavior. The good news is that ServiceNow supports several approaches to addressing this, such as integrated logging, debugging, and auditing. In this chapter, we'll be looking at those. Understanding auditing in ServiceNow ServiceNow has a dedicated audit table (sys_audit), which stores inserts and changes of records. You can access the change history of records from most form views. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to the Incident list view and select any incident. Before you check the audit history, it might be helpful to make an update or two to your record, so that you can see the audit list in action. 2. From the form view of the incident, right-click on the gray header bar and select History | List: 3. This will bring up a before-and-after view of every change made to your record, showing the before-and-after state of each field, the time stamp of the change, and a record of who made it: Often, when investigating an issue, we spend a large amount of time up front even just detecting the cause of an error. Taking a quick look at the history of a record can help you save that time, by showing the history in depth and in plain text. See also View audit history: https://docs.servicenow.com/bundle/jakarta-it-service-manage ment/page/product/service-catalog-management/task/t_ViewingAuditHistory.html Working with auditing tables Out of the box, some tables are already marked for audit, in which you can track the respective records. But if a table is not marked for audit, then you will not be able to track changes. In this recipe, you will see how you can mark any table for audit. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to System Definition | Dictionary. 2. From the Dictionary Entries list view, you'll see a column marked Audit, which will show true or false for each entry. To enable auditing for any of these, you can open the entry for that table, and set the Audit checkbox to true: 3. Going forward, entries for this table will have an audit history that can be accessed through the History | List option in the context menu. There's more... Audited tables receive a huge amount of activity and data which can introduce overhead and performance issues. This is something to take into consideration when you choose to make a table auditable. Additionally, the sys_audit table is intended for historical information purposes and can be kept indefinitely. At some point though, the data on the sys_audit table will become too cumbersome for day-to-day checks and queries. Out of the box, ServiceNow has a scheduled job called Table Cleaner, which can be used in case your table size gets out of hand. See also The sys_audit table: https://docs.servicenow.com/bundle/jakarta-platform-admini stration/page/administer/security/concept/c_UnderstandingTheSysAuditTable.html Understanding ServiceNow upgrades As a platform, ServiceNow has a goal to release two major platform upgrades a year. These are the named releases (Istanbul, Jakarta, and others), which are considered major releases that significantly change the existing platform. There are also periodic patch releases that occur, as needed. As such, it's likely that your ServiceNow implementation will be frequently refreshed to address bugs and to implement new features. Getting ready To use this recipe in Production instances, you should have special access to the ServiceNow HI Portal – https://hi.service-now.com. This is where customers can raise support-related issues or request upgrades or plugins to be deployed by ServiceNow Support. For the purposes of this demo, we will step through the upgrade process to the newly released Kingston version through our My Instance link at https: //developer.servicenow.com. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your My Instance interface at https://developer.serviceno w.com/app.do#!/instance. 2. On this screen, select the Action | Upgrade to Kingston option. You will be given the following warning before proceeding: If you're feeling brave, click Yes. 3. The upgrade process will take a short while. While it's underway, you'll have the following message on your My Instance console: You can monitor the console or watch your email to determine when the upgrade is complete. There's more... As mentioned previously, when you're managing paid instances, you'll request patches and major releases from the ServiceNow HI Portal. It's important to note that all processes of this type should be preceded by a review of the release notes and followed by regression testing of your newly upgraded instance. See also Upgrade your instance: https://docs.servicenow.com/bundle/jakarta-release-note s/page/release-notes/upgrades/concept/upgrades-overview.html#upgrades-overview Working with system logs Out of the box, ServiceNow provides several options for logging. There are general out-of-the-box logs for errors and warnings, as well as more granular logs such as transactions. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to System Logs | System Log, which will bring up a list view of all system messages throughout the current day: From this view, you can filter various log messages by type or search for keywords in the Message or Source fields. 2. At times, your users might report that ServiceNow is slow when accessing it from a particular location. In such cases, before drawing any conclusions, it might be valuable to take a look at the Transaction logs. 3. To do so, navigate to System Logs | Transactions which will bring up a list view of all individual transactions throughout the day. These entries can be filtered and searched similarly to the system logs, and can provide valuable time stamp information which can help with identifying performance-based issues: See also System logs: https://docs.servicenow.com/bundle/kingston-platform-admini stration/page/administer/time/reference/system-logs-2.html Transaction logs: https://docs.servicenow.com/bundle/kingston-platformadministration/page/administer/time/reference/transaction-logs-2.html Session debugging Enabling debugging is a simple process in ServiceNow and supports multiple levels of granularity, depending on where you're trying to pinpoint your investigation into the system plumbing. In this section, we will cover how to enable debugging and what to expect. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to System Diagnostics | Script Debugger | Session Debug | Enable All. In your normal operations, you will not default to turning on all debugging on your platform, especially in production. The amount of overhead invoked by global debugging should be avoided unless there are no other options. 2. Once you've enabled debugging, you should see your debugging output in any form or list view you browse to, by scrolling down below the existing form. It will be organized into several sections for consumption. Debugging information can used to detect failures or timeouts in expected operations. Additionally they can be used to detect operations that might be misconfigured or coded incorrectly, even if it's just a typo in a script or server side query: 3. Additionally, you will see security debug output below these sections. Here is a small sample: Security debug information will be very useful for determining what ACLs are granting (green checkmarks) and denying (red Xs) access to individual records or fields on a given record or other UI. If you wish to investigate any of the individual ACLs and their definition, you can use the related hyperlink next to the grant/deny icon. As covered in Chapter 1, Getting Started with ServiceNow, in order to modify ACLs, you must use the Elevate Roles option in the Profile menu to grant yourself the security_admin role. 4. When you've finished debugging, remember to navigate to System Diagnostics | Script Debugger | Session Debug | Disable All to turn off debugging. See also Debugging: https://docs.servicenow.com/bundle/kingston-application-development/p age/script/debugging/concept/c_SessionDebug.html Background scripts Background scripts are a very powerful tool for testing freeform JavaScript on your ServiceNow platform. They can be used to test scripts under development or to run tests against live data. Always remember that running background scripts represents running untested code on your platform. Proceed with caution! Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and an admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from the screencaps, my favorite is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to System Definition | Scripts | Background. This will bring up a pane where we can type some simple JavaScript and run it: 2. Here's some sample code that leverages the GlideSystem library: var c7 = 'Chapter 7'; var itsme = gs.getUserName(); gs.print(c7 + ' - '+ itsme); 3. Once you've entered your script, click the Run Script button. You should see an output similar to the following: The potential of background scripts as a testing and troubleshooting tool should be apparent. However, don't forget again that you're running live untested code in your environment. Normal practices around Javascript pitfalls do apply. (Infinite loops, anyone?) See also GlideSystem: https://docs.servicenow.com/bundle/kingston-application-d evelopment/page/app-store/dev_portal/API_reference/GlideSystem/concept/c_G lideSystemAPI.html Background scripts: https://docs.servicenow.com/bundle/kingston-appli cation-development/page/script/server-scripting/concept/c_ScriptsBackgroun d.html Service Portal In this chapter, we will be covering the following recipes: Configuring a portal Why mobile matters Branding and themes Portal branding Portal pages Portal widgets Building a new widget Introduction Beginning with the Helsinki release, ServiceNow introduced the new Service Portal. Intended as an alternative or replacement for the Content Management System (CMS), the Service Portal was a welcome addition to the platform, granting the ability to reuse existing content while opening up a new order of flexibility with greater web development options and better support for mobile, as well as implementing the AngularJS framework natively. Configuring a portal Although originally implemented as a single portal, the Service Portal module supports implementing as many portals as your customer base demands. In addition, many of the plugin applications available implement their own portal as a landing page for features relevant to them. Let's begin by taking a look at where portals are configured, and then launch one of our own. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Service Portal | Service Portal Home. This will open up a new window or tab that brings up the default Service Portal, which is available out of the box: From this page, users can search for relevant items from your Service Catalog and Knowledge Base or browse their open requests or incidents. Additionally, you can create links to other parts of your infrastructure or even incorporate third-party content. 2. We've seen a portal that's available out of the box, but what about creating our own? From your instance, navigate to Service Portal | Service Portal Configuration, which will bring up the Service Portal module administration page. From here, click on the New Portal option: 3. From the New Service Portal form, let's populate the following values and click on the Save button: 1. Title: Chapter 8 Service Portal 2. URL suffix: c8sp 3. Homepage: index 4. Login page: landing 5. Catalog: Technical Catalog 6. Main menu: SP Header Menu 7. Theme: Stock 4. Now, from your browser, navigate to https://{instancename}.servicenow.com/c8sp. You should see a page that looks mostly like the original Service Portal, but will have our new portal's title: It's just that easy to spawn a new portal for your users. You are able to control access to individual portals by setting up the Service Portal User Criteria Support plugin. Navigate to System Definition | Plugins and click the Activate/Upgrade link to enable this: Once you've activated the plug-in, navigate to Service Portal | Properties. Then set the Enable use of User Criteria records instead of Roles fields for Service Portal entitlements to Yes: Then click Save to fully enable the setting. Once this is enabled, you can edit individual Pages and Widgets to grant or deny access to individual components of the portal. For example, the index page of our new portal now have a Can View and Cannot View related list, each of which can be modified as needed to control access to sections of each portal: Now that we have a new portal in place, we will either continue to reuse the existing shared components or build new ones to implement unique features on our new portal. Throughout the remaining recipes in this chapter, we'll be doing a bit of both! See also Service Portal Configuration: https://docs.servicenow.com/bundle/kingston-ser vicenow-platform/page/build/service-portal/concept/service-portal-configuration-pag e.html Why mobile matters One of the major purposes of implementing the Service Portal module was creating a better experience for mobile users. As such, all of the content that you develop for your portals should be built with mobile in mind. Testing from multiple platforms and form factors is a base expectation when using the Service Portal. Additionally, refactoring existing content so that it will render and behave as expected on mobile devices is required. Where this is going to impact new adopters of Service Portal, the most are their catalogs, especially with the affected client scripts. In this recipe, we'll walk through a refactoring example. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Service Catalog | Catalog Administration | Catalog Client Scripts. 2. From the list view, find the script named Set Source, which is related to the Database Restore Technical Catalog item. 3. The intent of this catalog script is to dynamically set the source restore variable based on which database the user selects for restore. This has worked so far for users in the native interface. However, since the UI Type for the script is set for Desktop, it will not load or run in the Service Portal. In order to make this work, we will want to set the UI Type to All: 4. Once you've made this selection, click on Update. 5. After you've saved the client script, now it's time to test it out in the Service Portal. Navigate to https://{instancename}.servicenow.com/c8sp, which is the portal created in the beginning of this chapter. 6. In the How can we help? type-ahead search, type database, which should bring up Database Restore as one of the options: 7. Select it to bring up the catalog item. Once it's loaded, choose any of the options from the Database to restore field. The Restore from this source field should populate automatically: Although tedious, this refactoring process will be necessary to bringing your existing catalog content up to date so that it can be accessed in the Service Portal. Trust me, it's well worth the investment! See also Service Portal and Client Scripts: https://docs.servicenow.com/bundle/istanbul -servicenow-platform/page/build/service-portal/concept/unsupported_client_scripts.h tml Branding and themes We've seen how easy it is to stand up a Service Portal, but what about making it your own? That's where branding and themes come in. Let's walk through customizing our new portal. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. In addition, to get the most out of this section, you'll want to have gone through the first recipe in this chapter, Configuring a portal, to have the portal settings and components available that are referenced in the steps. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance. For example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Service Portal | Themes. From the list view, open the Stock theme. This is the theme that is currently referenced in our custom portal. 2. When doing custom development within ServiceNow, it's wise to fork existing content rather than overwrite it. In this way, you're preserving the original content for reference and in case you might need to rollback easily. To do this, we're going to type in a new name for the theme and then right-click the gray header bar to select Insert and Stay: After making your selection, you will have a fresh copy of the theme to make modifications to. 3. Next, we'll navigate to Service Portal | Portals and find our Chapter 8 Service Portal so that we can change the Theme to our new copy. From the portal view, change the Theme value to Chapter 8. After you've updated the value, click on Update: 4. Next, we're going to update the colors for our new theme. Navigate to Service Portal | Service Portal Configuration. When the selection page appears, choose the Branding Editor option: This will bring up the Branding Editor interface. Your settings will be in the left sidebar, and your changes will preview in the window on the right. Let's start with the Quick Setup tab. 5. The first option is the Portal title. We're going to leave that as is for now. Next, we have an option to upload an image. Let's upload the same image we're using in the ServiceNow native interface. 6. Click on Upload an image. Then, choose an appropriate file for upload. The preview will update accordingly: 7. Next, we'll move on to the Theme Colors tab. This will give us some CSS fields with which we can alter the colors used in the new portal. I'm going to borrow some of the values we used when updating the theme for the native platform. 8. Feel free to use whichever values you like, just to tinker. Here are the values I changed: 1. Navbar background: #0573f6 2. Navbar divider: #6c813f 3. Navbar link hover: #6c813f 4. Page background: #bdc0c4 9. When you're done making changes, navigate to your portal URL: https://{yourinstance}.service-now.com/c8sp. You should see the new theme changes there: As stated previously, don't underestimate the value of having an appealing design and user experience in your portal, especially if you have a large footprint of mobile users. You want your user base to come away with a great impression of your app. See also Portal Branding: https://docs.servicenow.com/bundle/kingston-servicenow-platfor m/page/build/service-portal/concept/c_BrandingEditor.html Portal pages Now that we've configured the top-level wireframe of our portal, it's time to add some page content. Let's take a look. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. In addition, to get the most out of this section, you'll want to have gone through the first recipe in this chapter, Configuring a portal to have the portal settings and components available that are referenced in the steps. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance; for example, https://{instancename}.service-now.com. Then, on the left-hand side in the search box, navigate to Service Portal | Pages. From the list view, find the index page that is our main homepage for our custom portal. 2. As stated in the previous recipe, I follow the philosophy of forking before you customize. Luckily, ServiceNow gives us a Clone Page button, which will copy the entire page as is, leaving us free to make any changes we like. 3. Click on the Clone Page button to get started: 4. You'll receive a success message at the top of the screen. Before we make changes to the newly cloned page, let's change the name to something more recognizable. Change the following values and then click on Update. 1. Title: Chapter 8 Index 2. ID: c8index 5. Now that we've got a new portal homepage, we'll want to update our portal to point to it. Navigate to Service Portal | Portals and find our Chapter 8 Service Portal to make these changes. 6. The Homepage value is a lookup field. Type-ahead with the ID value, you used on the cloned page to change the homepage: 7. Once you've selected the new homepage, click on Update. This will update the default homepage for our custom portal. 8. Now that we've forked the homepage, it's time to make it our own. Navigate to Service Portal | Service Portal Configuration to launch the portal development interface. From this page, click on the Page Editor section: 9. From the Page Editor screen, you can type ahead in the selection field to find our newly created page. The suggestions will display both the title and ID of the pages based on your search criteria. Let's find our c8index page: 10. Once you've selected the page, you'll see a screen with a hierarchical representation of all the components that form the page itself. They're organized into containers and widgets: Let's make some changes to the page by clicking on the Edit page in Designer link mentioned before the graphic. 11. From the Designer screen, we can rearrange existing components, add or delete new ones, and change the content associated with them. Let's start by changing the How can we help? message on the main screen. To do this, hover over the right-hand corner of the component and click on the pencil edit icon of that section of the page: 12. Change the Title value to something meaningful to you and then click on Save. 13. One other cool feature of the Page Designer is that it allows you to preview your pages in different form factors such as tablets or phone size screens. To see how this works, click on the Preview link at the top of the screen. On this screen, you'll see icons representing each of the form factors in the upper-right corner; let's see what the tablet interface will look like: 14. Clicking on the tablet icon gives me a narrowed-down rendering of all the components in a format more appropriate to that screen size: The Service Portal uses a library named Bootstrap to automatically make your pages and the underlying containers and widgets responsive to changes in browsers and various visual form factors. Using this structure, you are better able to focus on the functionality and features you implement in the portal, leaving the basics of the UI to the platform to manage automatically. See also Service Portal Pages: https://docs.servicenow.com/bundle/kingston-servicenow-pl atform/page/build/service-portal/concept/c_Pages.html Portal widgets When it comes to the true power and potential of the Service Portal module, widgets really are the heart. Each widget is a standalone Angular module that can be included in multiple pages or even multiple times in the same page. In this recipe, we'll walk through the anatomy of a widget and how to include them in your portal. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. In addition, to get the most out of this section, you'll want to have gone through the first recipe in this chapter, Configuring a portal, to have the portal settings and components available that are referenced in the steps. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance. For example, https://{instancename}.service-now.com, then on the left-hand side in the search box, navigate to Service Portal | Service Portal Configuration to access the Portal Configuration page. From here, select the Page Designer section and find our newly created index page, named c8index. On this page, the widgets are represented in dark blue. You can highlight any of these to view and change the widget. Let's highlight Simple List and take a look at how records are displayed on the portal: Each widget consists of an HTML template, a CSS section, and two scripting sections—client's side and server's side. AngularJS is included by default, and most features are supported within each widget. 2. If you review the code, you'll note a global variable being called frequently named c.options. This is a global variable that references the Angular controller (c) and an array of settings attached to it (options). These options are defined as a separate configuration in each instance of the widget. Instances of widgets use the same widget code, but with local versions of certain variables such as options. 3. For the purposes of this recipe, our leadership wants to add an additional list named My Changes. Since the title and table referenced by the list are called out in the options, the good news is we can reuse the Simple List widget to accomplish this. 4. Scroll up and click on the Edit Chapter 8 Index (c8index) page in Designer link to open the designer: The page designer is a What You See Is What You Get (WYSIWYG), editor where you can drag and drop components to the designer and experiment with different layouts. We will start by creating a new container to hold four lists instead of three. 5. Click, drag, and drop the 4-column container onto the designer. It will automatically create itself wherever you drop it: 6. Once the new container is in place, you can drag and drop the existing widgets to three of the new columns. Make sure to check the options for each one to ensure they match. Next, you can remove any existing widgets you no longer need: 7. Finally, we'll click, drag, and drop a new instance of the Simple List widget into the fourth column: 8. Now that we have a new copy of the widget, let's configure the options to have it reference the Change Request table. 9. Hover over the new widget and click on the edit (pencil) icon to open up the options interface. Once in the options list, enter the following values and click on Save: 1. Table: Change Request 2. Filter: active=true^assigned_to=javascript:getMyAssignm ents() 3. Display Field: Short Description 4. Secondary fields: Start Date There you go! As you can see, this is much easier than editing the code directly and also saves a great deal of effort by making the code reusable over time. Future updates to the Simple List widget will automatically apply to every instance. Therefore, care should be taken to ensure there is no regression with existing instances of the code. See also Service Portal widgets: https://docs.servicenow.com/bundle/kingston-servicenowplatform/page/build/service-portal/concept/c_Widgets.html Building a new widget So now we understand how to modify a page and reuse existing widgets, but what about creating our own? Let's take a deeper dive into the widget components and see what else we can accomplish. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance during Chapter 1, Getting Started with ServiceNow, that will be sufficient. In addition, to get the most out of this section, you'll want to have gone through the first recipe in this chapter, Configuring a portal, to have the portal settings and components available that are referenced in the steps. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance; for example, https://{instancename}.service-now.com, then, on left-hand side in the search box, navigate to Service Portal | Service Portal Configuration. From the Portal Configuration page, select the Widget Editor section: 2. From the Widget Editor screen, click on the Create a new widget link: 3. The Add a Widget dialog will pop up. Let's call it c8widget. Then, click on Submit: This will bring up the new widget interface. For the purposes of this recipe, we will be using the HTML template, the client script, and the server script panels. 4. Please populate the HTML Template with the following: <div> <h1> Hello, {{data.customer}}! Welcome to the Chapter 8 Widget! </h1> <h2> Based on your user data, we see that you are part of the {{data.department}} department </h2> <h2> The following users are logged into your instance <div ng-repeat="session in data.loggedInUsers"> <strong>{{session.name}}</strong> </div> </h2> </div> 5. Please populate the Client Script section with the following (it's the default value): function() { /* widget controller */ var c = this; } 6. Please populate the Server Script section with the following, and finally click on the Save button: (function() { data.customer = gs.getUserDisplayName(); data.department = ''; data.loggedInUsers = []; var gr = new GlideRecord('sys_user'); gr.addQuery('sys_id', gs.getUserID()); gr.query(); while (gr.next()){ data.department = gr.department.name.toString(); } var se = new GlideRecord('v_user_session'); se.addQuery('active',true); se.query(); while (se.next()){ var session = {}; session.name = se.user.toString(); data.loggedInUsers.push(session); } })(); 7. Once you've saved, you can click on the eye button right next to the Save button to see a preview of what your widget will display: This widget, or something like it, can now be added to any of your pages. There's more... This is just a small example of using the power of AngularJS to set up some HTML markup to receive data from ServiceNow, then run some server-side code to retrieve values based on who is logged in, and give some general data about the instance. You can expand on this as much as you like to provide status or urgent messages, visualize configurations, or integrate with third-party applications. Understanding Discovery Discovery is one of the more popular applications for customers once their ServiceNow platforms is up and running. What Discovery does is sends agentless probes out into specific IP ranges inside of your network to discover devices and their attributes, as well as the software and other middleware that might run on them. After running these probes, the data can be populated into your Configuration Management Database (CMDB) where work product from ITSM and other modules can be applied or otherwise related to it. This is useful for understanding what's happening where in your environments. See also Widget developer guide: https://docs.servicenow.com/bundle/kingstonservicenow-platform/page/build/service-portal/concept/widget-dev-guide.htm l Build a custom widget tutorial: https://docs.servicenow.com/bundle/k ingston-servicenow-platform/page/build/service-portal/concept/adv-widget-t utorial.html Overview of Additional Modules and Kingston In this chapter, we will be covering the following topics: Understanding Discovery Understanding Orchestration Service Mapping Cloud Management Governance, Risk, and Compliance Human Resources Edge Encryption Kingston – Flow Designer Kingston – Agent Intelligence Introduction By now, you've gotten a good overview of the base version of ServiceNow, including the ITSM core applications and the new Service Portal. However, this is just one pillar of the entire platform. ServiceNow offers a plethora of additional modules that can help customers continue to grow and improve their IT organization. The bulk of these are paid modules, but you are always able to experiment with and learn about them in your personal development instance. In these recipes, we will be covering basic installation and setup of each. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta or Kingston), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, it will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use Discovery, you must first install the necessary plugin from the Developer website. Navigate to https://developer.se rvicenow.com, log in with your credentials, and connect to the Manage Instance interface. 2. From the My Instance console, you'll select the Action drop-down menu and click on Activate plugin. This will bring up a list of plugins you can install for experimentation. Discovery is toward the top. When you find it, click on ACTIVATE. If the option is available to Include demo data, select that option for your personal development instance: The installation process for the various plugins takes a set amount of time, usually a few minutes, but can take longer. Once you get the confirmation message, you can then navigate to your instance: 3. Once the plugin is installed, you should have the Discovery application and its modules available in your Nav Bar. Because we don't have an actual infrastructure to discover, here are some of the basics of setting up the app: 1. Credentials: You'll need to define one or more accounts with administrator privileges to the devices you're attempting to discover. This will allow the process to pull information about the hardware and software on each node. 2. MID Servers: A MID Server is a customer-owned host, which acts as a delegate for processes such as Discovery. You'll need to provision an appropriate host with a Java Runtime Environment to support this service. 3. Discovery Schedules: Here, you'll actually define where and when discovery will take place. Schedules will be assigned an IP range, a category of nodes to discover, a MID Server, and a set time and frequency to run. See also Discovery: https://docs.servicenow.com/bundle/kingston-it-operations-man agement/page/product/discovery/reference/r-discovery.html MID Server: https://docs.servicenow.com/bundle/kingston-servicenow-pla tform/page/product/mid-server/reference/r-MIDServer.html Understanding Orchestration An important companion to the Discovery module is named Orchestration. What Orchestration does is send out tasks and other activity to your environment. It can be used to provision or retire resources, run installations, or change settings on nodes. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, it will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use Orchestration, you must first install the necessary plugin from the Developer website. Navigate to https://d eveloper.servicenow.com, log in with your credentials, and connect to the Manage Instance interface. 2. From the My Instance console, you'll select the Action drop-down menu, and click on Activate plugin. This will bring up a list of plugins you can install for experimentation. The Orchestration is around the middle. When you find it, click on ACTIVATE: The installation process for the various plugins takes a set amount of time, usually a few minutes, but can take longer. Once you get the confirmation message, you can then navigate to your instance. 3. Once the plugin is installed, you should have the Orchestration application and its modules available in your Nav Bar. One of the more notable additions will be some extra Activities available to your Workflows. To take a look, navigate to Orchestration | Workflow Editor. 4. On the right-hand sidebar, you'll see a tab named Packs, which contains a list of categories of Orchestration Activities: Once you have configured a MID Server and appropriate credentials, you will be able to incorporate these activities into workflows for automated processes. It's easy to see the potential of this module in saving time on repetitive tasks that can be prone to delays and human error. See also Orchestration: https://docs.servicenow.com/bundle/kingston-servicenow-p latform/page/product/orchestration/reference/r-orchestration.html MID Server: https://docs.servicenow.com/bundle/kingston-servicenow-pla tform/page/product/mid-server/reference/r-MIDServer.html Service Mapping An important outgrowth of Discovery is named Service Mapping. Service Mapping can help you define logical organizations of your resources into named services and other offerings of your organization. With Discovery as a dependency, the probes defined within Service Mapping can be used to look at the individual components that make up your environments and how they interconnect and combine to provide higher-level services that can be further mapped to your actual Service Catalog. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use Service Mapping, you must first install the necessary plugin from the Developer website. Navigate to https://d eveloper.servicenow.com, log in with your credentials, and connect to the Manage Instance interface. 2. From the My Instance console, you'll select the Action drop-down menu and click on Activate plugin. This will bring up an alphabetical list of plugins you can install for experimentation. Once you locate Service Mapping, click on ACTIVATE. If the option is available to Include demo data, select that option for your personal development instance: The installation process for the various plugins takes a set amount of time, usually a few minutes, but can take longer. Once you get the confirmation message, you can then navigate to your instance: 3. Let's take a quick look at the demo data to see what Service Mapping looks like. Navigate to Service Mapping | Home | Services | Business Services. This will bring up the list view of defined Business Services, their statuses, and criticality, as well as drill-down into a map of their components and how they build on each other. Let's click on the View map link under Customer Email: From the Service Map, you'll see a visual arrangement of the various nodes that combine to make the various services available. This is not only useful for predicting impacts to your infrastructure, but any change in status inside of the various nodes can be configured to send appropriate alerts to parties affected and personnel responsible for attending to those events: See also Service Mapping: https://docs.servicenow.com/bundle/kingston-it-operations-man agement/page/product/service-mapping/reference/c_ServiceMappingOverview.html Cloud Management With so many organizations undergoing a lift and shift to the Cloud, it becomes necessary for organizations to keep track of what's being provisioned on various providers. The examples of this can be AWS, Azure, and OpenStack. ServiceNow Cloud Management provides an option for connecting to each of your cloud providers and centralizing a view of those resources alongside your enterprise-hosted nodes. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use Cloud Management, you must first install the necessary plugin from the Developer website. Navigate to https://d eveloper.servicenow.com, log in with your credentials, and connect to the Manage Instance interface. 2. From the My Instance console, you'll select the Action drop-down menu and click on Activate plugin. This will bring up a list of plugins you can install for experimentation. When you find Cloud Management, click on ACTIVATE. If the option is available to Include demo data, select that option for your personal development instance: The installation process for the various plugins takes a set amount of time, usually a few minutes, but can take longer. Once you get the confirmation message, you can then navigate to your instance: 3. Connecting to your Cloud services is pretty straightforward. If you have an account with a cloud provider, you can connect your personal development instance to that service. To do so, navigate to Connections & Credentials | Credentials and click on the New button. You will be prompted to create credentials appropriate to your cloud offering. You can make a selection appropriate to your infrastructure from the Interceptor menu: For my example, I'm creating an AWS account: 4. With your credentials in place, navigate to Cloud Management | Service Accounts. Once there, click on the New button. 5. On this screen, populate the following values and click on Submit: 1. Name: Choose a name for your connection 2. Account ID: For AWS, this will be the 12-digit account number of your account 3. Discovery Credentials: Choose the credentials you created in the previous step 4. Datacenter Type: AWS Datacenter In order to do actual Discovery of Cloud resources, you will need to have a MID Server defined. If you like, you could provision a small VM on your Cloud service to host your MID Server. See also Cloud Management: https://docs.servicenow.com/bundle/kingston-it-operationsmanagement/page/product/cloud-management-v2/concept/cloud-management-v2-landing-pag e.html Governance, Risk, and Compliance One extremely important, yet oft-overlooked, discipline of IT organization is Compliance. Although its importance is universally understood, it can be difficult to prioritize preparation and discipline in this space. Luckily, ServiceNow provides a dedicated module, Governance, Risk, and Compliance (GRC), for keeping your policies and processes up to date with many public standards such as CobIT and ISO. Let's take a quick look. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use GRC, you must first install the necessary plugin inside your instance. Navigate to System Definition | Plugins and search for GRC: Policy and Compliance Management. Once you've located it, click on the Activate/Upgrade-related link in the lower left: 2. Check the Load demo data box and then click on Activate. An installation process dialog will run. Once it's complete, we can move on to looking at the module! 3. To take a look at the GRC module, let's start by navigating to Authority Documents. This list shows us our currently loaded compliance frameworks and their categories. These will help us define our controls and how they fulfill the various aspects of each framework: 4. While the Authority Documents define the goals of compliance, your Policy Statements create the relationship between your organization's behavior and commitments and those documents. To look at some sample statements, navigate to Policy and Compliance | Policies and Procedures | Policy Statements. From each of these, you can categorize the intent of the statement and track outstanding tasks intended to fulfill them: 5. To get an overview of your organization's compliance position, you can navigate to Policy and Compliance | Compliance | Overview to look at the dashboard, which shows the overall performance and metrics in this space: One of my favorite features of GRC is the ability to run inhouse Audits. (I like to call them Fire Drills) Instead of waiting until the day before, leadership can get a real-world view of the Compliance position of an organization outside of the normal cycle. You can find these under Compliance | Desired State | Audits. See also GRC: https://docs.servicenow.com/bundle/kingston-governance-risk-compliance/page /product/grc-common/reference/r_WhatIsGRC.html Human Resources IT isn't the only part of your organization that can benefit from ServiceNow. It provides a dedicated HR Service Delivery application that can implement an Employee Self Service experience for your internal users as well as guided onboarding for potential candidates. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use HR Service Delivery, you must first install the necessary plugin inside your instance. Navigate to System Definition | Plugins and search for Human Resources Scoped App: Core. Once you've located it, click on the Activate/Upgrade-related link in the lower left: 2. Check the Load demo data box and then click on Activate. An installation process dialog will run. Once it's complete, we will also install the Human Resources Scoped App: Service Portal. Once you've located it, click on the Activate/Upgraderelated link in the lower left: 3. Check the Load demo data box and then click on Activate. HR Service Management is a dedicated and compartmentalized module intended to offer a separate self-service experience for employees while still maintaining it on the ServiceNow platform. This includes a separate Service Portal, which can be found by navigating to Self Service | HR Service Portal. This will open a portal link at https://{instancename}.service-now.com/hrportal: The HR Portal can act as an employee-facing intranet with links to benefits or payroll information and their related requests. In addition, it can be extended to provide a public-facing experience for potential candidates or other interested parties to browse available requisitions or other information about your organization. The HR application provides dedicated security to ensure that sensitive or confidential information is not inappropriately shared, and offers e-signing features to capture official consent or acknowledgment of important documents electronically. See also HR Service Delivery: https://docs.servicenow.com/bundle/kingston-hr-service-de livery/page/product/human-resources/concept/hr-service-delivery.html Edge Encryption One concern that is frequently raised when investing in a cloud application, multitenant or other colocated environment is, How do I keep my data private? ServiceNow addresses this concern through the Edge Encryption solution. This allows customers to administer and control encryption of specific datasets with the added reassurance that they control the process beginning-to-end. Getting ready To use this recipe, you should have an active ServiceNow instance (Jakarta), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Before you can use Edge Encryption, you must first install the necessary plugin from the Developer website. Navigate to https://developer.servicenow.com, log in with your credentials, and connect to the Manage Instance interface. 2. From the My Instance console, you'll select the Action drop-down menu and click on Activate plugin. This will bring up a list of plugins you can install for experimentation. When you locate ServiceNow Edge Encryption, click on ACTIVATE. If the option is available to Include demo data, select that option for your personal development instance: The installation process for the various plugins takes a set amount of time, usually a few minutes, but can take longer. Once you get the confirmation message, you can then navigate to your instance: All ServiceNow side tasks associated with Edge Encryption require that you elevate your role to security_admin. This can be accomplished by navigating to the profile menu in the upper right and clicking on Elevate Roles. 3. To accomplish the basics of Edge Encryption, you'll need to determine which fields or data patterns will require encryption along with encryption protocols and key storage. Another required task will be configuring EE Proxy Servers to host your keys and actually manage the encryption traffic and overhead. These are hosted JVMs similar in provisioning and requirements to a MID Server. Downloads for the JVM are available by navigating to Edge Encryption Configuration | Installation & Downloads | Downloads. 4. Once you have one or more proxy servers in place, you can view existing encryption or create new ones by navigating to Edge Encryption Configuration | Encryption Configurations. See also Edge Encryption: https://docs.servicenow.com/bundle/kingston-servicen ow-platform/page/administer/edge-encryption/reference/edge-encryption.html EE Proxy Server: https://docs.servicenow.com/bundle/kingston-servicen ow-platform/page/administer/edge-encryption/task/t_DownloadtheProxy.html Kingston – Flow Designer As time of writing, the Kingston release of ServiceNow is only a couple of weeks old. Luckily, we were able to include up-to-date examples and documentation of the current version of some of the features. However, I thought it might be a good idea to touch on a couple of the highlights of the Kingston release since they were available, the first of which is Flow Designer. Getting ready To use this recipe, you should have an active ServiceNow instance (Kingston), valid credentials, and admin role. If you've provisioned a personal development instance in Chapter 1, Getting Started with ServiceNow, that will be sufficient. How to do it... Open any standard web browser. As you can tell from screencaps, my favorite to use is Chrome and follow these steps: 1. Navigate to your ServiceNow instance, for example, https://{instancename}.service-now.com. Then, on the lefthand side in the search box, navigate to ;Flow Designer | Designer. This will open up a new tab or window with the Flow Designer interface: 2. Flow Designer offers a no-code option for process owners to build life cycles and automated activities based on predefined actions. Click on the New button to create a New Flow. In this interface, let's build an automated flow when an emergency change is created. Name the flow something appropriate and click on Submit: 3. Flows consist of Triggers and Actions. Since we determined that we want this flow to fire when an emergency change is created, let's click on the + Add a Trigger button and define it as follows and click on Done. 1. Trigger: Created 2. Table: Change Request 3. Condition: Type is Emergency 4. Next, we need to choose an Action. We're going to send a Message to the Task Conversation indicating that an Emergency Change has been created. Click on the + Add an Action button and define it as follows: 1. Action: Send Message to Task Conversation 2. Task Record: Trigger->Change 3. Message: Emergency Request Record->Number Change Trigger -> Change Request Record -> NumberHas Been Created! Use the Data Pill Picker to include the dynamically defined fields in the code blocks. These can be staged to write from the newly created record. Now that you have a finished flow, click on the Save button. Then, you can click on Activate to make your flow occur every time the conditions are met. See also Flow Designer: https://docs.servicenow.com/bundle/kingston-servicenow-platform/ page/administer/flow-designer/concept/flow-designer.html Kingston – Agent Intelligence Another of the highly anticipated features with Kingston is the Agent Intelligence plugin. This module promises to enable machine learning and predictive modeling to help organizations optimize their routing and improve their processes. With Agent Intelligence, administrators are able to schedule jobs (essentially queries or reports) that gather and analyze work product such as incidents or other tasks and automatically set fields for future tasks such as assignment or categorization information. The premise of allowing an AI to do this is that it allows for dynamic and automatic modeling of routing and organization rather than manually curating assignment matrices that can change frequently. How to do it... Unfortunately, this plugin is only available if you have a paid instance of the ServiceNow platform. If you have access to one, you can request the plugin to be installed from the ServiceNow HI Portal at https://hi.service-no w.com/hisp. See also Agent Intelligence: https://docs.servicenow.com/bundle/kingston-servicenow-platf orm/page/administer/agent-intelligence/concept/agent-intelligence.html Other Books You May Enjoy If you enjoyed this book, you may be interested in these other books by Packt: ServiceNow Application Development Sagar Gupta ISBN: 978-1-78712-871-2 Customize the ServiceNow dashboard to meet your business requirements Use Administration and Security Controls to add roles and ensure proper access Manage tables and columns using data dictionaries Learn how application scopes are defined within ServiceNow Configure different types of table to design your application Start using the different types of scripting options available in ServiceNow Design and create workflows for task tables Use debugging techniques available in ServiceNow to easily resolve script-related issues Run scripts at regular time intervals using the Scheduled Script Execution module Learning ServiceNow Tim Woodruff ISBN: 978-1-78588-332-3 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 out Leave a review - let other readers know what you think Please share your thoughts on this book with others by leaving a review on the site that you bought it from. If you purchased the book from Amazon, please leave us an honest review on this book's Amazon page. This is vital so that other potential readers can see and use your unbiased opinion to make purchasing decisions, we can understand what our customers think about our products, and our authors can see your feedback on the title that they have worked with Packt to create. It will only take a few minutes of your time, but is valuable to other potential customers, our authors, and Packt. Thank you!