Need a Script for clone an incident record?

SiddiqB
Tera Contributor
 
3 REPLIES 3

HIROSHI SATOH
Mega Sage

There is a copy of the incident OOTB.

HIROSHISATOH_0-1725101851937.png

 

PrashantLearnIT
Tera Sage

Hi @SiddiqB 

 

Here is sample script -

 

// Business Rule or UI Action Script

(function() {
// Get the current incident record
var currentIncident = current;

// Create a new incident record
var newIncident = new GlideRecord('incident');
newIncident.initialize();

// Copy fields from the current incident to the new incident
newIncident.short_description = currentIncident.short_description + ' - Clone';
newIncident.description = currentIncident.description;
newIncident.category = currentIncident.category;
newIncident.subcategory = currentIncident.subcategory;
newIncident.priority = currentIncident.priority;
newIncident.urgency = currentIncident.urgency;
newIncident.impact = currentIncident.impact;
newIncident.assignment_group = currentIncident.assignment_group;
newIncident.assigned_to = currentIncident.assigned_to;
newIncident.caller_id = currentIncident.caller_id;
newIncident.contact_type = currentIncident.contact_type;
newIncident.state = currentIncident.state;
newIncident.location = currentIncident.location;
newIncident.u_custom_field = currentIncident.u_custom_field; // Example of a custom field

// Save the new incident record
newIncident.insert();

// Optional: Redirect the user to the new incident record
action.setRedirectURL(newIncident);

})();

 

 

var currentIncident = current;

 

what  I have to change here.