Duplication of tickets

shill
Mega Sage

We have a "duplicate ticket" UI action that we use when we need duplicate tickets made for multiple techs. One issue we find is that when the ticket is duplicated, the original ticket is no longer found in the assigned person's queue, nor the open ticket queue. We have to search for it in "all". Duplicated ticket shows up just fine.
This only occurs when the person opening the ticket duplicates it before submitting or updating. If they wait until after submitting, all is well, BUT the information from the original ticket (work_notes, additional comments) is lost.

Here is our script for Duplication.

//create a new Request record and populate fields
var inc = new GlideRecord("incident");
inc.short_description = current.short_description;
inc.location = current.location;
inc.department = current.u_department;
inc.description = current.description;
inc.requested_for = current.caller_id;
inc.contact_type = current.contact_type;
inc.watch_list = current.watch_list;
//inc.assigned_to = current.assigned_to;
//inc.assignment_group = current.assignment_group;
inc.system = current.u_system;
inc.Category = current.u_category;
inc.SubCategory = current.u_subcategory;
inc.Priority = current.priority;
inc.cmdb_ci = current.cmdb_ci;
inc.comments = current.comments;
inc.work_notes = current.work_notes;
inc.u_business_phone = current.u_business_phone;
inc.u_cell_phone = current.u_cell_phone;
inc.insert();

//Copy any attachments from the incident record to the request record
Packages.com.glide.ui.SysAttachment.copy("incident", current.sys_id, "incident", inc.sys_id);

//update existing Incident record
current.state = 1;
current.comments = "This incident has been duplicated to " + inc.number;
current.active = false;
current.update();

//provide onscreen feedback and set URLs
gs.addInfoMessage("Incident " + inc.number + " created");
action.setRedirectURL(inc);
action.setReturnURL(current);

Any ideas on why this is happening?

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Take the following line out of your script.

current.active = false;

Your queues probably have the filter active == true on them so that's why you're not seeing it.


Thanks, That appears to have corrected the problem.
It seems so obvious now 🙂

Steve