From 82fe3b38c1087900f59cff328d1281e4445d71bd Mon Sep 17 00:00:00 2001 From: anjimuvva <42597425+anjimuvva@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:45:17 +0800 Subject: [PATCH 1/4] Create identify_inactive_users_with_open_tickets.js --- .../identify_inactive_users_with_open_tickets.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Identify Inactive users with tickets/identify_inactive_users_with_open_tickets.js diff --git a/Server-Side Components/Background Scripts/Identify Inactive users with tickets/identify_inactive_users_with_open_tickets.js b/Server-Side Components/Background Scripts/Identify Inactive users with tickets/identify_inactive_users_with_open_tickets.js new file mode 100644 index 0000000000..aa83326a2e --- /dev/null +++ b/Server-Side Components/Background Scripts/Identify Inactive users with tickets/identify_inactive_users_with_open_tickets.js @@ -0,0 +1,12 @@ +var user = new GlideRecord('sys_user'); +user.addQuery('active', false); +user.query(); +while (user.next()) { + var inc = new GlideRecord('incident'); + inc.addQuery('assigned_to', user.sys_id); + inc.addQuery('state', '!=', 7); // not Closed + inc.query(); + while (inc.next()) { + gs.info('Inactive user with open ticket: ' + user.name + ' → ' + inc.number); + } +} From 101697bf902df131d0903b1994dff554498e3461 Mon Sep 17 00:00:00 2001 From: anjimuvva <42597425+anjimuvva@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:45:58 +0800 Subject: [PATCH 2/4] Create README.md --- .../Identify Inactive users with tickets/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Identify Inactive users with tickets/README.md diff --git a/Server-Side Components/Background Scripts/Identify Inactive users with tickets/README.md b/Server-Side Components/Background Scripts/Identify Inactive users with tickets/README.md new file mode 100644 index 0000000000..ddff5edf85 --- /dev/null +++ b/Server-Side Components/Background Scripts/Identify Inactive users with tickets/README.md @@ -0,0 +1,4 @@ +# ServiceNow Background Script – Identify Inactive Users with Open Incidents + +This background script helps admin to identify **inactive users** who still have **open incidents** assigned to them. +It’s particularly useful during **user cleanup, offboarding audits, or reassignment activities** to ensure no tickets remain unaddressed. From 8575dc92aac1a99e95ff4673522c39ca1be01e87 Mon Sep 17 00:00:00 2001 From: anjimuvva <42597425+anjimuvva@users.noreply.github.com> Date: Fri, 31 Oct 2025 00:09:04 +0800 Subject: [PATCH 3/4] Create create_request_using_script.js --- .../create_request_using_script.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Create Request through script/create_request_using_script.js diff --git a/Server-Side Components/Background Scripts/Create Request through script/create_request_using_script.js b/Server-Side Components/Background Scripts/Create Request through script/create_request_using_script.js new file mode 100644 index 0000000000..7df7e10663 --- /dev/null +++ b/Server-Side Components/Background Scripts/Create Request through script/create_request_using_script.js @@ -0,0 +1,24 @@ + +var cart = new sn_sc.CartJS(); +//define variables +var itemDetails = { + 'sysparm_id': 'catalog_item_sys_id', + 'variables': { + 'requested_for': 'user_sys_id' + /* + . + . + remaining variables + . + . + */ + } +}; + +// Add item to cart (returns item sys_id within the cart) +var cartItem = cart.addToCart(itemDetails); +gs.info('Added catalog item to cart: ' + cartItem); + +// -- Place the order --- +var order = cart.checkoutCart(); +gs.info('Order placed successfully. Request Sys ID: ' + order.request_id); From 2c81d3b73077dffa94fd43b8005cc174eee67e3e Mon Sep 17 00:00:00 2001 From: anjimuvva <42597425+anjimuvva@users.noreply.github.com> Date: Fri, 31 Oct 2025 00:11:33 +0800 Subject: [PATCH 4/4] Create README.md --- .../Create Request through script/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Create Request through script/README.md diff --git a/Server-Side Components/Background Scripts/Create Request through script/README.md b/Server-Side Components/Background Scripts/Create Request through script/README.md new file mode 100644 index 0000000000..3f07699f99 --- /dev/null +++ b/Server-Side Components/Background Scripts/Create Request through script/README.md @@ -0,0 +1,6 @@ +# ServiceNow Background Script – Create RITM via sn_sc.CartJS() + +## Overview +This script demonstrates how to programmatically create a **Request Item (RITM)** and **Request (REQ)** in ServiceNow using the modern **`sn_sc.CartJS()` API**. + +The script simulates a Service Catalog order submission — adding a catalog item to the cart and checking it out. This ensures that all **catalog flows, workflows, and business rules** are triggered exactly as if the request were placed through the Service Portal or native UI.