Master ServiceNow Scripting and ServiceNow GlideRecord

22-Day plan to master ServiceNow Scripting

Introduction 

There are three occasions in the life of a ServiceNow Developer when scripting plays the most important role :

▪️ ServiceNow Interviews 

▪️ Transition from Admin to Development 

▪️ Received a day-to-day project requirement and you are unable to find its solution on ServiceNow Community 

In this post, I’ll tell you how to start from 0 and become a hero in the ServiceNow scripting. The only ask is: Stay with me!

Prerequisites of ServiceNow Scripting

From the scripting perspective, the prerequisite that we can think of is basic JavaScript but to be honest, that is not mandatory. If you know it, that is certainly an add-on without a doubt. 

Also, from the ServiceNow perspective, it is important to know ServiceNow as a platform. So the CSA NowLearning course is really good if you are just starting. 

Since you are starting the scripting, I would highly recommend understanding ITSM as you might need multiple modules to practice from. I have already curated a complete path for ITSM. Please go through it, if possible.

Alright, so we can start now!

Day 1 (1.5 hours): Client Scripts, Methods

✅Go to ServiceNow Docs and understand client scripts and their types.

✅Once done, write a client script on the Incident table for each type.

✅Now, practice these methods : 

▪️getValue()

▪️addOption()

▪️clearOptions()

▪️addInfoMessage()

▪️addErrorMessage()

▪️showFieldMsg()

▪️clearMessages()

▪️getSections()

▪️getSectionName()

Day 2 (45 minutes): Client Scripts (continued)

✅ Revise the topics we discussed for Day – 1.

✅ Once done, write a client script while practicing GlideUser methods to fetch the User’s first name, full name, email, user ID, and user name.

✅ Next, practice how hasRole(), hasRoleExactly() playout with GlideUser.

Day 3 (1 hour): Some Glide Methods

✅ Revise the topics we discussed for Day – 1 & Day – 2 (15 minutes)

✅ Once done, write a client script and practice GlideList and the difference between v2 and v3 lists via scripts.

✅ Next, practice GlideModal and understand its real difference with GlideModalForm.

I am hopeful that you all have already started practicing/ revising these topics of ServiceNow scripting series.

Day 4 (2 hours): UI Policies 

✅ Revise the topics we discussed for Day – 2 & Day – 3 (15 minutes)

✅ We are done with the client scripts. Let’s move on to the UI Policy, to get an overview of it.

✅ Use mandatory, read-only, and visibility fields by using the below criteria on UI Policies and UI Policy Actions :

▪️Inherit

▪️View

▪️Reverse if False

▪️Clear the Variable Value

▪️OnLoad

▪️Execute if True

▪️Execute if False

▪️Use it on the Incident’s Related Lists

🎯 Some extra work: Give a read about other Glide methods used in client scripts & Understand why you should avoid GlideRecord.

how to learn ServiceNow scripting

Day 5 (1 hour): Revision 

✅ Revise the topics we discussed for Day-1, Day-2, Day-3 & Day-4

✅ No new topic today

Day 6 (1 hour): Server-Side Glide Methods in ServiceNow Scripting

✅ Now, we will move to Business Rules and try them out on the Incident table.

✅ But before we do, please understand a few important glide methods for today :

▪️GlideRecord 

▪️GlideAggregate 

▪️GlideSystem

▪️GlideDate & GlideDateTime

Day 7 (2 hours): Server-Side Glide Methods, Business Rules 

✅ Revise the Glide Methods (including ServiceNow GlideRecord) we discussed yesterday (15 minutes).

✅  Let’s move on to some other important glide methods for today :

▪️Scoped GlideSystem

▪️GlideRecordSecure

▪️GlideQuery

✅ Read thoroughly the types of Business Rules and how they are executed.

🎯 On a rough note, the execution is something like this –

Before Query ➡️ Display ➡️ Before ➡️ After ➡️ Async 

✅ So we will practice them in the above order only. But for today, practice these two only : 

▪️Query

▪️Display

Day 8 (2 hours): Business Rules (continued)

✅ Revise Day 7 topics (15 minutes).

✅ We will continue to practice other types of Business Rules : 

▪️Before 

▪️After

▪️Async

✅ I know you might be looking for scenarios. Although I created some scenario-based Business Rules questions on LinkedIn, let me tell you how to create some scenarios on your own : 

[i] Go to Business Rules 

[ii] For example Filter by Query Business Rules 

[iii] Open the simplest Business Rule you find

[iv] Deactivate it 

[v] Create a Business Rule that has the same functionality as the OOB and add any functionality on top of it of your choice

[vi] Test it out

Day 9 (2 hours): Debug Business Rules 

✅ Revise Day-8 topics (15 minutes).

✅ Today we will practice the most underrated topic of ServiceNow scripting but we do need them at some point : 

▪️gs methods (info, warn, etc.)

▪️Script Debugger (Understand how to use proper breakpoints & log points)

▪️Script Tracer

Day 10 (2 hours): Revision 

✅ Revise the topics we discussed for Day-6, Day-7, Day-8 & Day-9

✅ No new topic today

Day 11 (2 hours): Script Includes

✅ Now, we will be working on #ScriptIncludes and need to practice multiple script includes considering below scenarios :

▪️OnDemand Script Include 

▪️’ A newly defined class’ script includes

▪️’ Extend existing class’ script include

Note: Do not practice Client Callable Script Includes today.

Day 12 (2 hours): Script Includes (Continued)

✅ Revise Day-11 topics (15 minutes).

✅ Now, practice a sub-part of ‘Extend existing class’ which is Client Callable Script Include.

This last one is way more important to understand because it establishes communication between the client and the server.

✅ So if we are using a client callable script include, we are going to play around with a Client Script that contains GlideAjax and make a trip to the server.

Tip: Please practice JSON and the use of stringify parse functions 

✅ It is very important to understand when to use get XML, getXMLWait, and getXMLAnswer on the client side

Day 13 (2 hours): Script Includes (Continued)

✅ Revise Day-12 topics (15 minutes).

✅ Call a script include in business rules, return a value from that script include, and receive the value back in the business rule.

✅ Leverage Script Include from the Advanced Reference Qualifier.

✅ Very important to understand the use of Baseline Script Includes to assign constant strings to actual values.

A good practice for reusability, that’s the reason we use Script Includes, right?

✅ Clone a Script Include and reuse it by adding a functionality on top of it.

✅ Now you should be able to compare the display business rules we discussed in the last post and the GlideAjax functionality.

Day 14 (2 hours): Flow Designer 

✅ Revise Day-13 topics (15 minutes).

✅ Today we will proceed with the Flow Designer.

First, understand these :

▪️Flows, Subflows, Actions

▪️Trigger (Application, Record and Schedule Based)

▪️Data Pills / Data Panel

✅ Once understood, execute a small flow on the incident table. 

You may try this : 

➡️ Create an Action on the incident table

➡️ Create a Subflow and call that action.

➡️ Try calling that Subflow from the Flow.

How to start learning ServiceNow scripting from scratch?

Day 15 (2 hours): Flow Designer (Continued)

✅ You need to understand three very important APIs while practicing ServiceNow scripting :

▪️FlowAPI

▪️FlowScriptAPI

▪️GlideFlowAPI

And in that too, a few important functions (at least from the beginner’s standpoint) – getRunner(), getContextID(), startFlow(), etc.

If you have the bandwidth for more, it would be really good. But these three may work for now.

Note: Please do your research as a few methods are deprecated as well.

✅ Time for Action Designer Script Step!

Understand these things below and practice them :

▪️Inputs, Outputs

▪️Script Steps

▪️Error Evaluation 

▪️Business logic 

✅ Test your Action, Flow, and Subflow.

Day 16 (2 hours): Revision 

✅ Revise the topics we discussed for Day-11, Day-12, Day-13, Day-14 & Day-15

✅ No new topic today

Day 17 (3 hours): Application Development 

✅ Understand various kinds of Applications :

▪️ServiceNow Applications (Plugins)

▪️Partner Applications

▪️Custom Applications

✅ Next, what are the scoped apps and delegated development?

Understand why we need Scoped Apps in the first place.

You must be wondering if this is ServiceNow scripting. Well, let me tell you about it on Day 18 part.

✅ The most crucial step while creating an application is the designing.

You need to consider multiple aspects including :

▪️Number of stakeholders 

▪️Personas

▪️Tables Involved

▪️Do you need integration?

▪️What emails are you going to send?

▪️How can you automate this stuff?

It is indeed a never-ending list.

Day 18 (2.5 hours): Application Development (continued)

✅ Use Guided App Creator to build the application from scratch and continue building it within the Studio

✅ In the Modules/Application, get hold of the Controls tab and then the very important Application Access tab, especially these :

▪️CanRead, CanUpdate, CanDelete, CanCreate

▪️Can Web Services make that call?

▪️Protection Policy 

▪️Caller Access Records (Cross-Scope)

▪️Accessible From

✅ So here is our practice part – Scripting

▪️Use already created Script Includes previously.

▪️Create Business Rules (and other scripts) in your new scoped app.

▪️Try calling the Script Includes from these scoped scripts.

▪️Play around with the checkboxes mentioned in the previous step.

Day 19 (2.5 hours): UI Actions, Events and Notifications 

✅ First let’s do some action, yeah our next step of ServiceNow scripting is UI Actions.

You must analyze both aspects of this coin, the server side, and the client side.

Try them as form links, buttons, list choices, etc.

✅ Second we’ll drive the email part :

▪️Event Registry, Logs

▪️Email Templates, Layouts

▪️Email Notifications 

▪️Email Notification Scripts

▪️SMS

▪️Script Actions

Now trigger the events from different scripts you have learned and you should be good here.

Day 20 (2.5 hours): Inbound Email Actions, Data Policies, ACL Scripts 

✅ Inbound Email Actions

Understand these fields/ script objects :

▪️Action Type

▪️Stop Processing 

▪️Watermark 

▪️Type

▪️Required Roles

▪️From

▪️current 

▪️event

▪️email

▪️logger

✅ Data Policies

✅ ACL Scripts

Day 21 (3.5 hours): Transform Map Scripts, Scheduled Jobs and Others 

✅ Transform Map Scripts (All types)

✅ Scheduled Jobs

✅ UI Pages

✅ Macros

Day 22 (2 hours): Revision 

✅ Revise the topics we discussed for Day-17, Day-18, Day-19, Day-20, and Day-21.

FAQs

What scripting is used in ServiceNow?

JavaScript is used in ServiceNow

What are the 4 types of client scripts in ServiceNow?

OnChange, OnLoad, OnCellEdit, and OnSubmit are the 4 types of client scripts used in ServiceNow

How to practice ServiceNow scripting?

Please go through the post and you can master it in 22 days

Which script runs first in ServiceNow?

Before Business rules with order less than 1000 runs first in ServiceNow

Does ServiceNow have coding?

Yes, although it is inclined towards low code or no code, it requires scripting as well to make complex changes

Leave a Comment

Your email address will not be published. Required fields are marked *