Duplicate incidents are created with same incident number but different sys_id?

sahin_ponhadan
Kilo Contributor

Hi ,

 

We have a issue in our service now instance , duplicate incidents are created with same incident number for the same issue.   sys_id of these duplicate incidents are different. As an example we have one incident having   two duplicate tickets   and for another one there are 5 duplicate tickets. Till now we came across four such incidents. Client reported this by saying that "When caller/user reply to the notification (Incident INCXXXXXXX is opened on your behalf),it create another ticket with same Incident number" . But why it occured to only those four ? Whether any one faced such an issue ? What will be the cause for this?

19 REPLIES 19

mpeace
Giga Contributor

Hi Sahin,



This issue is caused when users double click the "Submit" button.   From what I understand this is a known issue and the way to prevent it is to make the ticket number "unique".   In the task table dictionary record for "number", you can personalize the form and add the "unique" field.   Check this box and save the record to enforce primary key constraints for the ticket number.



Note that before you can do this, you will first need to identify and remove all duplicate numbers on the task table.   To identify the duplicates, create a client callable script include named dupTasks with the following code:



function dupTasks() {


  var dupRecords = [];


  var gaDupCheck1 = new GlideAggregate('task');


  gaDupCheck1.addAggregate('COUNT', 'number');


  gaDupCheck1.groupBy('number');


  gaDupCheck1.addHaving('COUNT', '>', 1);


  gaDupCheck1.query();


  while (gaDupCheck1.next()) {


  dupRecords.push(gaDupCheck1.number.toString());


  }


  return dupRecords;


}



Now, navigate to task.list and enter the filter:   "Number" "Is" "javascript:dupTasks()" and click Run.   I will let you decide on how you should handle removing the duplicates.  






brian_degroot
ServiceNow Employee
ServiceNow Employee

When you submit a record, the form is set to read only and the submission actions are blocked. When the server is done processing, there is a slight window between the new page and the unload event of the current page where if you click on the button in that timeframe, the form is enabled and able to be clicked on thus creating the duplicate record.



Since the issue is UI related, an alternate solution to this can be to hide the submission actions when the form is submitted. This would essentially eliminate the possibility of this happening. You can do this through an onSubmit() Client Script on the task table using the following code:



// This script will hide the Submit UI Actions when a form is submitted


function onSubmit() {        


              var hideMe = document.getElementsByTagName("button");  


              if (hideMe) {  


                      for (var i=0; i < hideMe.length; i++) {  


                              var testClass = hideMe[i];


  var t1 = 'form_action_button   action_context btn btn-default'   // these are the class of buttons that appear at the top of the form


  var t2 = 'form_action_button header   action_context btn btn-default' //these are the class of buttons that appear at the bottom


              if ((testClass.className == t1 || t2 )   && (testClass.id == 'sysverb_insert'))


                          hideMe[i].style.display = 'none';                  


          }


    }  


}  



Hi,



Is there a way to delete nearly 8000 duplicate records in incident by running a script? I already found out how to find duplicates from different places.



Thanks


Ak


mrbenwhite
Tera Contributor

Good Morning,

I have a scenario where the incident number is different for the duplicates but the short description, category, subcategory, symptom, impact, urgency, priority, configuration item and incident creator are all the same - multiple incidents/copies created when we just one is needed? 

I tried 'This issue is caused when users double click the "Submit" button' but couldn't reproduce this.

Harshal Aditya
Mega Sage
Mega Sage

Hi Sahin,

 

May be possible the duplicate incident are coming from different service-now instance. This mainly occurs because of an servicenow to servicenow integration or when using XML to update incidents.

 

Regards

Harshal