
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 08:40 AM
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();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 08:42 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 08:54 AM
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();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 06:49 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 06:52 AM
Been there - done that. Hated it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 06:52 AM
Aha! It was something doubling it up!