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

Mahira
Tera Guru

Hi Sahin,



We had a similar issue at a client after Calgary update. How we efixed it is by cleaning up all duplicate entries and then updating the number field on the number maintenance record for that table. The number should be either   greater than or equal to the highest number in the incident list ; for eg if your highest incident number is INC176601 then update the number field in the number maintenance record for incident to 176601 . Hope this helps



Regards,


Mahira



shab121
Kilo Contributor

Hi Mahira ,


for me cleaning up is not option . I need to assign them new numbers .


I picked up highest available number and updated records by incrementing one at a time .


so new records are like INC00092,INC00093,INC00094,INC00095,INC00096.



then I tried to create a new incident from UI , they not only gets numbers as INC00092,INC00093,INC00094,INC00095,INC00096


but also getting saved , although unique attribute is   enabled in Dictionary .



-Shabbir


Hi Shabbir,,


What is the current number in your number maintenance record for incident table?



Regards,


Mahira


Hi Shabbir,



By Number maintenance I mean to go to the Number Maintenance module on the left hand navigation area.



I haven't tried this but my thoughts on your course of action should be


1)Assign new incident numbers to the duplicate records since you cannot delete them


2) Change the number maintenance number (by going to left handside module) to the highest number


3)start creating new incidents from the UI


Regards,


Mahira


shab121
Kilo Contributor

Hi Mahira ,


We have used this script to fox the issue .



===========================



var typeSearchFor = 'incident';



var records = [];



records = getDuplicates(typeSearchFor);



var duplicateRecordIndex;



for (duplicateRecordIndex = 0; duplicateRecordIndex < records.length; duplicateRecordIndex++)



        {



                  gs.print(records[duplicateRecordIndex]);



                  update(records[duplicateRecordIndex]);



        }



function getDuplicates(type) {



        var dupRecords = [];



        var gaDupCheck1 = new GlideAggregate(type);



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


        gaDupCheck1.addNotNullQuery('number');



        gaDupCheck1.groupBy('number');



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



        gaDupCheck1.query();



        while (gaDupCheck1.next()) {



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



                            gs.print("getDuplicates Type" + type + " : " + gaDupCheck1.number.toString() + "\n");



              }



                  return dupRecords;



        }



function update(candidate) {



        var rec = new GlideRecord(typeSearchFor );



        rec.addQuery('number', candidate);



        rec.query();



        var count = rec.getRowCount();



        gs.print( candidate+" "+ typeSearchFor +'count' + count);



        var index = 0;



        while (rec.next()){



        if (index == 0){



                  gs.print("no change " + rec.number); index++; continue;



                }



                  var newNumber = GlideNumberManager.getNumber(typeSearchFor);



                  gs.print(rec.number + ': changeded incident number : ' + newNumber);



                  rec.number = newNumber;



                  rec.update();



                  index++;



        }



}