Category

Scripting

Elevate your ServiceNow development skills with our comprehensive resources on JavaScript and GlideRecord, the powerful tools to manipulate data and customize y

Dec 16, 2023

The Role of isInteractive() in GlideSession Handling

Leveraging isInteractive() in ServiceNow for Enhanced Session Management As a ServiceNow developer, differentiating between interactive and non-interactive sessions has been a key aspect of my projects, ensuring tailored experiences for various user interactions. isInteractive() is

Read article →
Dec 16, 2023

How To Add A Message With addMessage(), Info or Error

The Significance of addMessage() in ServiceNow Development In my journey as a ServiceNow developer, one of the most impactful ways I’ve found to enhance user experience is through effective communication within the application. This is

Read article →
Dec 16, 2023

How To Use setLimit() To Return A Set Number Of Rows In A GlideRecordQuery()

The Strategic Application of setLimit() in Data Queries In my experience as a ServiceNow developer, managing data retrieval efficiently is key to maintaining system performance and user satisfaction. This is where setLimit() in GlideRecord queries

Read article →
Dec 16, 2023

How To Use setForceUpdate() To Force An Update With GlideRecord In ServiceNow

Effectively Utilizing setForceUpdate() in ServiceNow GlideRecord Queries In my journey as a ServiceNow developer, I’ve often encountered situations where I needed to ensure that a record was updated regardless of whether any fields had changed.

Read article →
Dec 16, 2023

How To Use setDisplayValue() To Set A Display Value

As a ServiceNow developer, one of the most intriguing tasks I’ve encountered was ensuring data accuracy and relevance, especially when dealing with reference and date/time fields. This is where setDisplayValue() comes into play in GlideRecord

Read article →
Dec 15, 2023

How To Properly Use orderBy() In A GlideRecord Query In ServiceNow

The Importance of orderBy() in Structuring Data As a ServiceNow developer, I’ve often faced the challenge of fetching and presenting data in a specific order. This is where orderBy() in GlideRecord queries becomes a game-changer.

Read article →
Dec 15, 2023

How To Get The Current CRUD Operation Name In A Script, with current.operation()

In my experience as a ServiceNow developer, understanding the context of data manipulation is crucial, particularly when working with business rules. This is where the operation() method in GlideRecord queries becomes invaluable. It allows you

Read article →
Dec 15, 2023

How To Get A Table Name with getTableName()

As a ServiceNow developer, one of the most fundamental yet crucial tasks is to understand and interact with various data tables. Here, getTableName() in GlideRecord queries plays an essential role. This method fetches the name

Read article →
Dec 15, 2023

How To Properly Use getEncodedQuery() In A GlideRecord Query

As a seasoned ServiceNow developer, I’ve come to appreciate the power of getEncodedQuery() in GlideRecord queries. This method retrieves the current query conditions as an encoded query string, which is a compact representation of the

Read article →
Dec 15, 2023

How To Delete Multiple Records With deleteMultiple()

NOTE: Be careful with deleteMultiple() – You are deleting data. Use with caution. The Strategic Use of deleteMultiple() As a ServiceNow Developer/Consultant, I’ve often encountered situations where bulk deletion of records is necessary. This is

Read article →
Dec 15, 2023

How To Use addInactiveQuery() In A GlideRecordQuery

Understanding the Need for addInactiveQuery() In the nuanced world of ServiceNow development, there are scenarios where accessing inactive records is just as crucial as fetching active ones. This is where addInactiveQuery() becomes an invaluable tool

Read article →
Dec 15, 2023

How To Use addActiveQuery() In A GlideRecord Query

Enhancing Query Efficiency with addActiveQuery() I alway smile when I see someone using addActiveQuery(), over gr.addQuery(“active”, true);. The addActiveQuery() function plays a crucial role in this process. This method is a streamlined approach to filter

Read article →
Dec 15, 2023

How To Get The Display Value Of A Reference Field Via A Client Script – g_form.getDisplayBox()

Unlocking the Potential of g_form.getDisplayBox() In the world of ServiceNow development, accessing display values of reference fields is a common requirement. This is where g_form.getDisplayBox() comes into play. It’s an effective method for retrieving the

Read article →
Dec 15, 2023

How To Use g_form.getReference() In A Client Script

Understanding the Role of g_form.getReference() When developing in ServiceNow, understanding the utility of g_form.getReference() is crucial. This function is a key tool for retrieving GlideRecord objects for specific fields in client scripts. What sets it

Read article →
Aug 9, 2023

How To Add A Worknote To A Task, When It’s Approved

ServiceNow Approvals – Adding A Worknote To The Task, When Approved ServiceNow, as one of the most comprehensive and scalable IT Service Management platforms, offers numerous features designed to streamline the flow of business processes.

Read article →
Jul 16, 2023

Understanding Key Value Pairs In A JSON Object In ServiceNow

What Are Key Value Pairs In JSON? In the realm of ServiceNow scripting, understanding how to navigate key-value pairs in an object is fundamental. Why? Because they form the bedrock of data organization in objects,

Read article →
Jul 16, 2023

Using nil() To Check For null Values With GlideRecords

What Is nil()? Scripting in ServiceNow serves as a powerful tool for developers and administrators to manipulate and manage data. A key part of this toolbox is the nil() method. Simply put, nil() is a

Read article →
Jul 16, 2023

Creating Records With GlideRecord initialize() and insert()

What Are initialize() and insert()? In ServiceNow scripting, a common requirement is to create new records in a table. While this can be done manually through the UI, using scripts with initialize() and insert() methods

Read article →
Jan 13, 2023

How To Use setValue() In A GlideRecord Query

What Is The setValue() Method? When you’re building out a GlideRecord query, you’ll frequently want to set a value, in your while loop. The setValue() method in a GlideRecord query is a method that allows

Read article →
Jan 12, 2023

What Is The g_form() Object?

What Is g_form()? Fundamentally, g_form is a global JavaScript object that provides a number of methods for interacting with and manipulating forms in the ServiceNow platform. It essentially just allows ServiceNow developers to interact with

Read article →
Jan 4, 2023

How To Use orderBy() To Sort By A Field Value

Why Use The orderBy() Method? What is orderBy() and why would you ever use it? Great question, we’d love to address it below. There are a number of reasons why you might want to order

Read article →
Jan 3, 2023

Can I Use A GlideRecord Query In A Client Script? No, Don’t Do It.

GlideRecord On The Client vs Server If you ever see a GlideRecord query, anywhere on the client side, it’s a HUGE red flag. It indicates that whomever implemented the solution doesn’t have any respect for

Read article →
Dec 21, 2022

Get The Difference Between Two Dates With subtract()

Use subtract() To Get A Date Difference Here is a quick server side script where you can get the duration difference, between 2 GlideDateTime objects. Remember that this is only available to run on the

Read article →
Dec 21, 2022

How To Add Days To A Date With GlideDateTime() and addDays()

How To Add Days To A Date Scripting with time in ServiceNow can keep you up at night. It can be tricky, difficult to get things to work, and there doesn’t seem to be great

Read article →
Dec 20, 2022

Require Worknotes when Resolving an Incident with a Business Rule

Why Require Work Notes, When Resolving/Closing an Incident? This requirement should be default in all ServiceNow instances. Especially for P1/P2 incidents. You’ll see this request come in from IT managers, because it enriches a companies

Read article →
Dec 19, 2022

How To Save A Record Using g_form.save() On The Client

What Is g_form.save() There are so many use cases for this to be implemented. The scenario is that you’re working with a form, in some client scripting capacity – client script, UI Action, etc. You

Read article →
Dec 18, 2022

Prevent Submission Of A Form With an onSubmit() Client Script

Why Would You Want To Prevent A Form From Being Submitted In ServiceNow? This is a fairly common request that comes in from our end users. Sometimes, we need to engage in some data validation,

Read article →
Dec 14, 2022

Require A Minimum Length For A Field

Why Create A Minimum Field Length Requirement Say your end users aren’t filling out certain forms, as well as you’d like them to. As admins in the platform, along with many other features, we have

Read article →
Dec 9, 2022

How To Use GlideAjax in ServiceNow – A Complete Guide

What Is GlideAjax? If you’re a ServiceNow Admin or Developer, then you know what it’s like to be working on a client side script, when you need to access server side data. We would heavily

Read article →
Oct 4, 2022

What Does setWorkflow(false) Do – In A Background Script?

When you’re performing bulk operations via script, you want to make sure that you keep “data integrity” in mind, of the records and tables you’re updating. You want to make the data as real and

Read article →
Oct 3, 2022

How To Create A Recurring Task – Use Scheduled Jobs

What Is A Scheduled Job? A scheduled job in ServiceNow is an action (usually a script) that is executed, based on a schedule. Say for example, that you’d like to create an incident, a change

Read article →
Aug 30, 2022

How To Force A Record To An Update Set – UI Action

If you’re a ServiceNow Admin, you first off understand what an update set is, and you understand what types of records are captured, and which are not. If you write a business rule in an

Read article →
Aug 24, 2022

How To Add A Worknote To An Incident With A Script

There are a couple of ways to add a worknote to an incident. Below, we’ll cover adding a work_note to an incident with a business rule, and then we’ll also cover how to add a

Read article →
Aug 23, 2022

How To Use gs.getUser().isMemberOf()

When scripting in ServiceNow, you’ll frequently have to create conditional statements around users and their group membership. Based upon what group a certain user is in, we want to either allow or even disallow certain

Read article →
Aug 23, 2022

Get All Of The Groups For A User

This script will print all of the groups a member is in, in ServiceNow. Below, we query the [sys_user_grmember] table and find all of the groups where the user field is the sys_id of a

Read article →
Aug 23, 2022

ServiceNow GlideDateTime() – Get The Current Date And Time

Scripting around dates and time in ServiceNow has caused every ServiceNow Engineer some pain at a certain point. Here’s how to get the current date and time in ServiceNow. This will be a super simple

Read article →
Aug 22, 2022

How To Use getDisplayValue() and GlideRecord

When you’re scripting with reference field’s and sys_id’s, understanding how to use getDisplayValue() is incredibly useful. Anytime you see a reference field on a form, you need to know that the true value of that

Read article →
Aug 10, 2022

How To Get The Username Of Current User – User Object gs.getUser()

When you are scripting around the current user, you’ll find that the user object comes in handy. There are often times you’ll need to perform some certain behavior around the current user who’s logged in.

Read article →
Jul 8, 2022

How To Clear The Cache in ServiceNow

Clearing the instance cache is a crucial component of being a ServiceNow Admin/Developer. If you don’t understand how and when to clear the cache, you might be wasting a lot of time chasing a customization

Read article →
May 13, 2022

Logging In Custom Apps – Don’t Use gs.log()

If you’re a ServiceNow Admin, you’re very familiar with the idea of using gs.log(). It’s an extremely common scripting practice to see what the output of a value is. We use this every day in

Read article →
Aug 23, 2021

Don’t Update System Fields With autoSysFields(false)

When To Use autoSysFields(false) As a ServiceNow Admin, you’ve most likely experienced this scenario before. You need to bulk update a few hundred records, by adding a worknote for example, but that’s all you want

Read article →
Aug 23, 2021

How To Write An Async Business Rule in ServiceNow

Understanding Async Business Rules All ServiceNow Admins need to understand when to use an async business rule, and when not to. An async business rule is similar to an after business rule, in that it

Read article →
Aug 11, 2021

Restricting Access – ACL vs. Before Query Business Rule

How To Prohibit Access When most ServiceNow Admins think about granting or restricting access, the first thing that comes to mind is ACL (Access Control Rule) configuration. And usually, they would be correct. ACL’s are

Read article →
Aug 9, 2021

Organize System Logs By Using A Source with gs.log()

Add A Source To gs.log(value, source) ServiceNow environments can create millions of system logs on a daily basis. And no one has time to manually sort through them. So unless your exporting this data to

Read article →
Aug 9, 2021

How To Show An Info or Error Message On A Form

Informational and Error Messages with g_form() Sometimes, you want to show everyone visiting a certain form some information. Say you’re experiencing an outage, or there’s a message you want to broadcast to everyone using a

Read article →
Jul 28, 2021

Use get() to get One or Many Records With GlideRecord

Use get() with ServiceNow

Read article →
Jul 28, 2021

How To Use addEncodedQuery() with GlideRecord in ServiceNow

What is addEncodedQuery() This is something that will end up saving you a lot of time and can make your GlideRecord queries a lot cleaner and shorter. Being a ServiceNow Admin is all about learning

Read article →
Jul 20, 2021

How To Use addOrCondition() with GlideRecord

Want To Add An OR Condition To A GlideRecord Query? As an admin, you need to be comfortable with GlideRecord scripting on the server. The addOrCondition() is amazingly helpful and I use it on a

Read article →
Jul 16, 2021

How To Add A Button To The Incident Form

Adding A UI Action (Button) To Any Form In ServiceNow, admins can configure all aspects of a form. This includes fields, relationships between these fields, the UI of the form, and also – UI Actions.

Read article →
Jul 14, 2021

Don’t Create An Approval, If Task Is Assigned To Approver

Don’t Allow Approval To Be Created, If Task Is Assigned To That User How do we stop an approval from being created, if the associated task is assigned to that user? We don’t want people

Read article →
Jul 12, 2021

How To Delete (And Restore) Records With A Background Script

Deleting Multiple Records In ServiceNow, a background script is an admins best friend. It allows you to run scripts to directly interact with your database. This can be incredibly helpful and save you a tremendous

Read article →
Jul 8, 2021

How To Randomly Auto Assign Tasks in ServiceNow

Auto Assign Capabilities – What is Out Of Box? By default, when any record is assigned to a group, there’s no automatic behavior to update the “Assigned to” user. There is no round robin or

Read article →
Jul 7, 2021

How To Call a Script Include from a Business Rule In ServiceNow

Overview Have you ever wanted to call a Script Include, directly from a Business Rule? This is a common method to keep your business rules clean. It’s especially useful if you plan on repeatedly calling

Read article →
Jul 2, 2021

Only Send Approval Requests to Active Users

Creating An Approval This is something, that in my opinion, should be out of box functionality – but is not. But the benefit of a platform like ServiceNow is that it allows you to create

Read article →
Jul 1, 2021

How To Understand, Create and Reference System Properties in ServiceNow

What are System Properties? System properties in ServiceNow control thousands of specific options regarding the behavior and configuration of the platform. This is incredibly far ranging, but it includes modifying the color scheme, how long

Read article →
Jul 1, 2021

Prohibit An Insert or Update with setAbortAction(true)

When To Use setAbortAction() A common use case in ServiceNow for an Admin or Developer is to not allow a record to be inserted or updated, under certain conditions. This is where the method setAbortAction()

Read article →
Jun 30, 2021

Create An Incident via Background Script

A background script in ServiceNow can be used to create, update or delete many records on the server. We will create an incident record using GlideRecord here as an example. Make sure to try it out in a sub production instance first.

Read article →
Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode