Book Image

ServiceNow: Building Powerful Workflows

By : Tim Woodruff, Martin Wood, Ashish Rudra Srivastava
Book Image

ServiceNow: Building Powerful Workflows

By: Tim Woodruff, Martin Wood, Ashish Rudra Srivastava

Overview of this book

ServiceNow is a SaaS application that provides workflow form-based applications. It is an ideal platform for creating enterprise-level applications, giving requesters and fulfillers improved visibility and access to a process. ServiceNow-based applications often replace email by providing a better way to get work done. This course will show you how to put important ServiceNow features to work in the real world. We will introduce key concepts and examples on managing and automating IT services, and help you build a solid foundation towards this new approach. You will then learn more about the power of tasks, events, and notifications. We’ll then focus on using web services and other mechanisms to integrate ServiceNow with other systems. Further on, you’ll learn how to secure applications and data, and understand how ServiceNow performs logging and error reporting. At the end of this course, you will acquire immediately applicable skills to rectify everyday problems encountered on the ServiceNow platform. The course provides you with highly practical content explaining ServiceNow from the following Packt books: 1. Learning ServiceNow 2. ServiceNow Cookbook 3. Mastering ServiceNow, Second Edition
Table of Contents (39 chapters)
Title Page
Credits
Preface
Free Chapter
1
Module 1
36
Bibliography

Scripting in UI Policies


UI Policy conditions are evaluated both on-load (if the On Load tick-box is selected on the Advanced view) and whenever an update is made to any field on a form in ServiceNow. When an update is made, the condition on the UI Policy is re-evaluated. If the condition returns true, then the UI Policy Actions run. If the conditions return false (and Reverse if false is enabled) then the opposite of the UI Policy Actions run.

Understanding that these events all happen within the browser (AKA the client) tells us that UI Policies are evaluated client-side. In the Advanced view of the UI Policy form, there is a Script section. In this section, if the Run Scripts tick-box is selected, two script input fields will be displayed: Execute if true, and Execute if false. Each script has a pre-defined default value, which acts as the scaffolding for the script:

function onCondition() { 

} 

Any code you write inside of that function will be executed client-side, and thus will have...