seeing duplicate incidents with same number

Gangadhar Ravi
Giga Sage
Giga Sage

Hi,

We are finding duplicate incidents created with same numbers. and I found there is a OOB unique option. Setting unique to true on number field will solve that issue? and does anyone have any idea what is the root cause of this issue?

find_real_file.png

Thanks,

Ganga

1 ACCEPTED SOLUTION

Ubada Barmawar
Giga Guru

Hi @Gangadhar Ravi 

 

I have recently overcome this issue. the below given solutions may help.

solution1 :

go to the dictionary of number field, you can set the default value of the number field as

 

UbadaBarmawar_0-1708449517108.png

solution2 : 

go to the system properties list and search for "glide.itil.assign.number.on.insert", and set the value as 'true'.

 

UbadaBarmawar_1-1708449825425.png

 

 

please mark it as helpful and "accept as solution".

 

regards,

Ubada Barmawar.

 

 

View solution in original post

5 REPLIES 5

Shishir Srivast
Mega Sage

Shiraz2
Mega Guru

Apparently, duplicate numbering could happen as there is no checks in place for it to NOT happen. We opened a HI ticket and found out this is by Design. One solution is as follows:



Create a before Insert business Rule as follows:


//


// checks if a duplicate number exists and if so get the next one.


//


checkNumber();


function checkNumber()


{


var gr = new GlideRecord('table');   //Change the 'table' to the table you want this business rule to apply.


gr.addQuery("number", current.number);


gr.query();


if (gr.next()) {


var oldnumber = current.number; current.number = getNextObjNumber();


gs.log("renumbered record number " + oldnumber + " to " + current.number + " because it was a duplicate");


  }


}



I hope this helps.


VaranAwesomenow
Mega Sage

Dear Gangadhar,


We implemented it by creating a before insert business rule that runs on table ( ex: incident).



find_real_file.png




find_real_file.png




(function executeRule(current, previous /*null when async*/) {




// Add your code here


var gr = new GlideRecord('incident');


gr.addQuery('number', current.number);


gr.query();


if(gr.next()) {


gs.addErrorMessage("An incident is already present with the same number " + current.number);


current.setAbortAction(true);


}




})(current, previous);



The tricky part is to test this solution, cos system wont let us create a record directly on that table from UI as the number field is read only. I used the REST API explorer to create a record.



find_real_file.png


find_real_file.png



find_real_file.png



find_real_file.png



Thanks


Anil


Marshall Day
Mega Expert

Gangadhar,

I have recently run into this issue and although the above responses are correct I feel there is a simpler way that works for all tables that use numbering coming from the Task table.

 

Create the business rule as described in the "Enforcing unique numbering" from the link below.

https://docs.servicenow.com/bundle/kingston-platform-administration/page/administer/field-administration/concept/c_EnforcingUniqueNumbering.html

When you select the table for the BR, select the TASK table. This will allow the BR to run on all numbering tables that extend from the Task table (Incident, Request, Problem, etc). Anyone that creates a new record will have this before insert rule determine if the number is the next number in line and not a duplicate of a previous one.

 

You can test this out in any sub-production environment by changing the Number Count for that table back one number and creating a new record. The BR will find that the number has been used and will automatically bump it to the next number available.

 

Hope this helps.

 

Marshall