Skip to content

Instantly share code, notes, and snippets.

@icerge
Last active April 20, 2021 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icerge/76a625af06a9b422754080d37e28b57e to your computer and use it in GitHub Desktop.
Save icerge/76a625af06a9b422754080d37e28b57e to your computer and use it in GitHub Desktop.
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, cmdb_ci_storage_device.computer 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. cmdb_os_user.computer and cmdb_ci_storage_device.computer have computer and a_ref_3 aliases.

What do we know about variables?

Tables

Let's take a look from request perspective:

  • sc_req_item is a request item table
  • sc_item_option_mtom is a m2m table to keep links between a request item and a variable value
  • sc_item_option is a table of variable values (options)

Now let's take a cart perspective:

  • sc_cart is a table where all cart records are present
  • sc_cart_item is a table of request items in a cart
  • sc_item_option is a table of variables and their values (options) of the items in a cart

APIs

It's mentioned somewhere in OOTB code. If I reference a variable Order From in a business rule of a request item, I'll get a reference to an instance of something sort of GlideElement. Suppose it's a v - reference to a variable. Then the following chain of methods is available.

var question = v.getGlideObject().getQuestion();

question.getLabel();
// "Order From"

You can list available attributes in the js object question for more methods. In fact all variable properties are accessible from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment