Get Next Incremental Number skipping values

Katie A
Mega Guru

Hello, I have a Business Rule on the CMDB CI Computer table that will create a new asset tag "BEFORE" "INSERT".

I noticed that the auto-number counter is SKIPPING values. It starts at 30,000 and creates the new asset tag but it only creates even-numbers. So it started at 30,000 and the next one was 30,0002 and the next was 30,0004 and 30,0006 etc.

I have tested this by creating a bunch of new computers and each time it SKIPS the next odd number and jumps ahead to the next even number.

What could be the issue?

function onBefore(current, previous) {

  //Set asset tag incremental number maintenance counter on Configuration Item table

  current.asset_tag = getNextObjNumberPadded();

}

Screen Shot 2016-05-11 at 11.54.53 AM.png

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,



By default, numbers are generated every time a new record is created. When records are created but not saved, a gap in the numbering is created. To generate numbers only when records are saved, navigate to System Properties > System and set the property Assign a task number only upon insert (prevents unused numbers) to true


http://wiki.servicenow.com/index.php?title=Managing_Record_Numbering#Preventing_Numbering_Gaps.


View solution in original post

13 REPLIES 13

I tried an onAfter business rule but it didn't work, the values are still skipping to the next one.



function onAfter(current, previous) {


  //Set asset tag incremental number maintenance counter on Configuration Item table


  current.asset_tag = getNextObjNumberPadded();


  current.setWorkflow(false); // Do not run business rules


  current.autoSysFields(false); // Do not update system fields


  current.update();


}


Katie A
Mega Guru

The root cause of the issue was that there was another field on that table (a custom field created years ago by a previous administrator) that was also using the same numbering script. So I removed that field and it is working. Thanks all for the help.


Been there - done that. Hated it.


Community Alums
Not applicable

Aha! It was something doubling it up!