diff --git a/Server-Side Components/Background Scripts/Get Orphan Incidents/README.md b/Server-Side Components/Background Scripts/Get Orphan Incidents/README.md new file mode 100644 index 0000000000..4ada11859d --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Orphan Incidents/README.md @@ -0,0 +1,5 @@ +# ServiceNow Background Script – Find Orphaned Incidents + + +This background script helps to identify **orphaned incident records** — incidents that are not assigned to any **user** or **assignment group** and are still open. + diff --git a/Server-Side Components/Background Scripts/Get Orphan Incidents/get_orphan_incidents.js b/Server-Side Components/Background Scripts/Get Orphan Incidents/get_orphan_incidents.js new file mode 100644 index 0000000000..cdfe89cab9 --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Orphan Incidents/get_orphan_incidents.js @@ -0,0 +1,9 @@ +var gr = new GlideRecord('incident'); +gr.addNullQuery('assigned_to'); +gr.addNullQuery('assignment_group'); +gr.addQuery('state', '!=', 7); // not closed +gr.query(); +gs.info("Orphaned incidents count:"+gr.getRowCount()); +while (gr.next()) { + gs.info('Orphaned incident: ' + gr.number + ' - ' + gr.short_description); +} diff --git a/Server-Side Components/Background Scripts/Identify Inactive Users with Open Tickets/README.md b/Server-Side Components/Background Scripts/Identify Inactive Users with Open Tickets/README.md new file mode 100644 index 0000000000..ddff5edf85 --- /dev/null +++ b/Server-Side Components/Background Scripts/Identify Inactive Users with Open 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. diff --git a/Server-Side Components/Background Scripts/Identify Inactive Users with Open Tickets/identify_inactive_users_with_open_tickets.js b/Server-Side Components/Background Scripts/Identify Inactive Users with Open 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 Open 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); + } +}