Skip to content

Instantly share code, notes, and snippets.

icerge /
Last active April 12, 2024 02:47
Development and configuration patterns in ServiceNow

Ajax calls from Native forms and Catalog items

Client script + UI Script + Script Include (Ajax) + Script Include (API)

Client script is a calling side. Optionally, it may be wrapped into a UI Script to form re-usable Client side API.

Script Include (Ajax) is an interface for client side interactions it fetches parameters, validate them and call necessary APIs.

Script Include (API) implements server side functionalities that may and most probably will be used by both Client and Server side logic. No Ajax parameters are available in context, they are supplied as method arguments.

Naming convention

icerge / get URL
Last active December 6, 2023 11:40
Server side story of how to get URL parameters



Another longer alternative:

icerge / code reviews agains HS and
Last active March 26, 2021 13:57
Notes made from HS issues review. Collection of object misuses or interesting observations.

Global UI Scripts

It is an eval from BP perspective and HS doesn't like it either.

I found two basic mistakes in configurations.

As Source file for JS Include

You put a shared code or a 3rd party lib to UI Script and include it to a widget. Global checkbox is redundant. Any UI Script will be loaded.

As shared lib for form client side scripts

Yea, good motivation, avoid code duplication. Any shared functionality can be put to UI script and loaded in client side

icerge /
Created November 4, 2020 13:41
ServiceNow - Approval types

Approval types

Requirement justification

We had a very similar requirement due to the multiple number of different approvals needed for our Change process to be able to display an Approval Type to our approvals. We were able to accomplish this by performing the following configurations:

Technical design

  1. Add a column to the Approval table [sysapproval_approval]. For our solution we simply added a Choice type column called Approval Type [u_type]. We then created the choices we needed in the Choices related list.
  2. Next we modified the Workflow Activity Definitions for each of the Approval Workflow Activities. You can find these by searching for Workflow Activity Definitions in the navigator. For example, open the Approval - User definition record. Scroll down to the Activity Variables tab and click the New button to add a new variable. This will seem very familiar if you have created Catalog variables. For our solution our variable was created with the following attributes:
  • Column name = u_appr
icerge /
Last active November 17, 2021 16:58
Security: ACLs, Query Business Rules

Number of rows removed due to security constraint

User gets this message in a list of records whenever there is a record user doesn't have rights to view. I.e. there is an ACL restricting access to a record or there in NO ACL granting the access. Let's ignore security mode setting here.

It's a default system beharior.

Would you like to get rid of it? System to count with records user has access to?

Solution 1

Replicate row level read access ACLs to query business rules. Naturally, every query will get controlled.

icerge / confirm
Last active April 17, 2024 12:35
Using modal windows in SN: GlideModal, confirm onSubmit

get confirmation in onSubmit client script

Have you ever got into this trap?

I'd like to make a confirmation with user that he/she are certain about submit/save/update action using a client script. This is the case. I can use a dumb confirm dialog which isn't cute at all. I can also try to use a GlideModal overlay with rich UI Page content. Why not?!

Well, because of

  • the fact that submit action has been already initiated from onSubmit function of Client Script perspective
  • and
icerge /
Last active April 20, 2021 14:55
Collection of admin tools and features

Column aliases

ServiceNow maintains a table of field-column name mappings: sys_storage_alias. It is especially useful when reviewing list of indexes available in a table like cmdb_ci_storage_device. Index definition may include a storage alias instead of human-readable name of the field.

For example, field has a storage alias a_ref_3.

Reason for alias use is probably related to the way table structure is organized. Alias (most probably) won't be used if table is stand-alone. If table is part of hierarchy and table-per-hierarchy or table-per-partition extension models are used, then column with the same names will to be mapped to aliases. E.g. and have computer and a_ref_3 aliases.

What do we know about variables?

icerge /
Created January 2, 2019 12:05
Enrich Send/Receive Email posts of Activity log

Use case

I'd like to reply to an email recieved in a ticket... right from the activity log.

Sample idea - Render reply/reply all buttons

Add UI controls to Activity formatter

It's actually a processor - EmailDisplay. Locate function writeBody and construct output HTML sample before it is printed.


Seen in

LabelsAjax (


  • assign
  • assignLabel
  • getLabelEntries
icerge /
Last active December 6, 2023 11:52
REST API things

Import Set API

Custom response

For any good reason I need to get more things in my Import Set response for REST interface. Ok, I just go to Transform map, use Explicit script, that script right in the transform map record, type there:

response.custom_element = "Welcome, REST response extension!";

and enJoy the Rest of the day! :)

Note, credits go to SN community. Stay brave!