Skip to content

Instantly share code, notes, and snippets.

@codaroma
codaroma / count_refs1.js
Last active September 4, 2025 03:28
Count reference to legacy SW models
/*jshint esversion: 6 */
(function () {
function getReferences(table) {
var result = [];
var gr = new GlideRecord("sys_dictionary");
var query = [
["nameSTARTSWITHcmdb_ci", "element!=model_id"],
[
"glidefunction:substring(name, 1, 7)!=cmdb_ci",
"glidefunction:substring(name, 1, 5)!=var__",
@codaroma
codaroma / decode_hub_v2.js
Last active June 27, 2025 03:14
decode_hub_v2.js
(async () => {
if (!g_form) return;
const map = {
sys_hub_action_instance_v2: "values",
sys_hub_flow_logic_instance_v2: "values",
sys_hub_sub_flow_instance_v2: "subflow_inputs",
sys_hub_trigger_instance_v2: "trigger_inputs",
sys_flow_context_inputs_chunk: "data",
};
const table = g_form.getTableName();
@codaroma
codaroma / sn-refresh-installed-apps.js
Last active January 24, 2025 01:42
ServiceNow script to update existing store applications
/**
* Find all store applications that have a newer version available
* exclude apps with compatibility issues
* create a batch install plan to update them to the latest version
* pass the plan to sn_appclient.AppManagerAPI.installBatch
*/
var result = (function () {
new sn_appclient.UpdateChecker().checkAvailableUpdates();
var storeApp = new GlideRecord("sys_store_app");
@codaroma
codaroma / SimpleQueryAjax.js
Last active April 23, 2024 11:28
ServiceNow SimpleQueryAjax.js Script Include
/**
* Example usage
*
* function onChange(control, oldValue, newValue, isLoading) {
* if (isLoading || newValue == "") {
* return;
* }
*
* var ajax = new GlideAjax("SimpleQueryAjax");
* ajax.addParam(