Duplicate records with same number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
When records are imported through Data Import Sets, the record numbers are not being generated in the correct sequence. Instead, the numbers are getting assigned in a jumbled or non-sequential order.
Also, when we create records manually, sometimes a number that already exists is being assigned to a new record. Although the record numbers are the same, their sys id values are different.
Could you please help us understand why this is happening and how we can fix the issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @vijani
This is usually caused by one of these:
- The transform map sets the Number field. Imported numbers are written directly and the number counter doesn't advance, so manually created records later get duplicate numbers. Fix: remove the number mapping, or move the counter past the highest imported number.
- Numbers are assigned when the form loads. Abandoned forms use up numbers. Fix: set glide.itil.assign.number.on.insert to true.
- Fix the counter. In System Definition > Number Maintenance and sys_number_counter, set the counter above the highest existing number, and check that no other table uses the same prefix.
Renumber the existing duplicates with a fix script, after taking a backup.
If this helped, please mark it as the accepted solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @HasanM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @vijani
As the Number field isn't mapped, the counter was probably reset or lowered at some point. Common causes are an update set or clone that brought in an older sys_number record, or a script that sets current.number.
Increasing the counter is the recommended fix. Update sys_number_counter for that table to a value above the highest existing number (editing sys_number alone may not change the counter that's in use). Then create a test record to confirm the next number is correct. This stops new duplicates, but you'll need to renumber the existing ones with a fix script, after taking a backup.
If this helped, please mark it as the accepted solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Both issues usually come from how ServiceNow assigns numbers, and they often share a root cause.
How numbering works
The Number field gets its value from a dictionary default (getNextObjNumberPadded()). This reads the prefix and digit settings from Number Maintenance (sys_number) and increments the counter in sys_number_counter. The number is only a unique identifier. The platform does not promise that numbers will be gapless or follow creation order.
Why imports produce non-sequential numbers
- Concurrent imports: if Concurrent Import is enabled on the data source, the import set is split into partitions that transform in parallel. Rows pick up the next counter value in whatever order the threads reach them, not in source file order.
- Row order: the transform doesn’t guarantee it will process rows in the order they appear in the source file.
- Other activity during the import: users or integrations creating records at the same time take numbers from the same counter, which leaves gaps.
Why manually created records get duplicate numbers
- Imported numbers: if the transform map writes legacy numbers straight into Number, the counter isn’t advanced. Once the counter catches up with the imported range, new records are given numbers that already exist.
- Insert / Insert and Stay: using either on an existing record creates a new record (new sys_id) that keeps the original number. This is a very common cause.
- Counter changes: someone edited the counter or Number Maintenance record by hand, or an instance was cloned or restored and the counter is now lower than the highest number in the table.
How to fix it
- Compare the highest number on the table with the counter in Number Maintenance. If the counter is lower, set it above the highest existing number.
- Stop mapping source numbers to Number in the transform map. If you need to keep legacy references, put them in a separate field (for example Correlation ID or a custom legacy number field).
- Set the system property glide.itil.assign.number.on.insert to true. Numbers are then assigned when the record is saved rather than when the form loads, which prevents gaps from abandoned forms and stops Insert / Insert and Stay from carrying the old number onto the new record.
- If ordering within an import matters to you, turn off Concurrent Import on the data source. Even then, treat the number as an identifier and use Created for sequencing.
- Find the existing duplicates (group the table by Number where the count is greater than 1) and renumber the newer records. Do this before anything references them.