Skip to Main Content
Mastering ServiceNow Scripting
book

Mastering ServiceNow Scripting

by Andrew Kindred
February 2018
Intermediate to advanced content levelIntermediate to advanced
226 pages
5h 13m
English
Packt Publishing
Content preview from Mastering ServiceNow Scripting

Script examples

Now that we have seen how the basics of server-side scripting work, we can take a look at some scripting examples to further our knowledge of how to use these introductory server-side techniques.

We'll start with a further business rule example.

This time, we will create a before delete business rule to ensure that directors are not deleted. We need to set the business rule to advanced; select the delete checkbox and before in the When field. Let's have a look at the code:

(function executeRule(current, previous /*null when async*/) {  if (current.title == 'Director') {    gs.addErrorMessage('Cannot delete Director');    current.setAbortAction(true);    action.setRedirectURL(current);  }})(current, previous);

Here, we are checking whether ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PowerShell Cookbook, 4th Edition

PowerShell Cookbook, 4th Edition

Lee Holmes
Learning Splunk

Learning Splunk

Tom Kopchak

Publisher Resources

ISBN: 9781788627092Supplemental Content