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] 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'); +}