Need a Script for clone an incident record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2024 10:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2024 03:57 AM
There is a copy of the incident OOTB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2024 06:23 AM
Hi @Siddiqbasha
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);
})();
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2024 08:41 AM
var currentIncident = current;
what I have to change here.