From 6f7f61066848fb60b24622c1d4675310760bf2c7 Mon Sep 17 00:00:00 2001 From: Thrizvi <145013431+Thrizvi@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:00:22 +0530 Subject: [PATCH 1/2] Create IncidentToChange.js Clone Incident Data into a New Change Request --- .../IncidentToChange.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Copy table fields from one table to another/IncidentToChange.js diff --git a/Server-Side Components/Background Scripts/Copy table fields from one table to another/IncidentToChange.js b/Server-Side Components/Background Scripts/Copy table fields from one table to another/IncidentToChange.js new file mode 100644 index 0000000000..affb9ada41 --- /dev/null +++ b/Server-Side Components/Background Scripts/Copy table fields from one table to another/IncidentToChange.js @@ -0,0 +1,25 @@ +var incidentGR = new GlideRecord('incident'); + +// Replace with actual incident number or sys_id +if (incidentGR.get('number', 'INC0010001')) { // any incident + var changeGR = new GlideRecord('change_request'); + changeGR.initialize(); + + // Copy relevant fields from incident to change request + changeGR.short_description = 'Change for Incident: ' + incidentGR.short_description; + changeGR.description = incidentGR.description; + changeGR.priority = incidentGR.priority; + changeGR.impact = incidentGR.impact; + changeGR.urgency = incidentGR.urgency; + changeGR.category = incidentGR.category; + changeGR.caller_id = incidentGR.caller_id; + changeGR.cmdb_ci = incidentGR.cmdb_ci; // If CI is linked + changeGR.assignment_group = incidentGR.assignment_group; + changeGR.assigned_to = incidentGR.assigned_to; + + // Insert the new change request + var newChangeID = changeGR.insert(); + gs.info('New Change Request created with sys_id: ' + newChangeID); +} else { + gs.info('Incident not found'); +} From ea0dda2fbef8130a67a59fd7cada0f5467488bda Mon Sep 17 00:00:00 2001 From: Thrizvi <145013431+Thrizvi@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:50:43 +0530 Subject: [PATCH 2/2] Update script.js Updating the user record for first and last name --- .../Updating a record in the sys_user table/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server-Side Components/Background Scripts/Updating a record in the sys_user table/script.js b/Server-Side Components/Background Scripts/Updating a record in the sys_user table/script.js index e483846890..a2a3bf1254 100644 --- a/Server-Side Components/Background Scripts/Updating a record in the sys_user table/script.js +++ b/Server-Side Components/Background Scripts/Updating a record in the sys_user table/script.js @@ -2,8 +2,8 @@ var grUser = new GlideRecord('sys_user'); if (grUser.get('62826bf03710200044e0bfc8bcbe5df9')) { grUser.user_name = 'test.user'; - grUser.first_name = 'test'; - grUser.last_name = 'user'; + grUser.first_name = 'test1'; + grUser.last_name = 'user1'; grUser.email = 'test.user@servicenow'; grUser.update(); } else {