
- 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: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:52 AM
Thank you. I did try this but it is still skipping values unfortunately.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 08:43 AM
Try async or after. I had similar issues with the system trying to create duplicates setting a field with a before BR before.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 08:49 AM
NO NO NO, Ben! You know better than that. 🙂 Don't set current.anything in an async or after if you can help it.
Business Rules Best Practices - ServiceNow Wiki
There's no current.update() after/async so people put one in, that triggers the business rules again (which causes business rules to run again.) See the issue here?
If you want the next number, use it as a default value in the dictionary. See task.number as an example.