Number Maintenance - digit overflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2010 10:40 PM
In the number maintenance you can create your own number ranges and create new numbers with getNextObjNumberPadded(). That's ok so far.
What would happen, if the number range runs into an overflow. You've got for example INC9999999 and then calls getNextObjNumberPadded.
How can we be prepared for this case?
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2010 06:10 AM
It appears as though the numbering system will still generate the next number in the series (and extending the number of digits). I did a couple of simple tests to confirm this and that appears to be the behavior. So in the case you list above, you will get INC10000000 as the next number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2010 06:55 AM
To add what Jacob said
Question: Currently our incidents are numbered INCxxxxx. What will happen when we get to number INC99999? Will it roll back over and create a duplicate ticket number or will it add in a 6th number?
Solution: It will add a 6th digit, and your numbers will sort incorrectly until a script is run to pad the 5-digit numbers. Enhancements have been made for the Winter 2010 release to automatically do this padding when the "Maximum digits" field is changed in System Definition --> Number Maintenance for a given table, but until then the script is manually run.
Here is the script we use to pad numbers when necessary. It will probably not format correctly here, but we can get you a formatted copy if you like.
If you roll over 100000 and the numbers don't sort correctly, sorting on the Created field will sort as expected. Once the script is run with the right variable values, the number field will sort as expected once again.
You can also look on our /demo instance at a business rule on the sys_number table. It runs a function in the recently modified "NumberManager" Script Include to automatically do the padding when the "Maximum digits" field is changed for a table in System Definition --> Number Maintenance (which links to the sys_number table).
/* Task Number Padding Script */

/* numDigits - desired number of digits */

/* tableName - target table */


var numDigits = 7;

var tableName = "incident";

var prefix;

var currentNumber;


var number = new GlideRecord("sys_number");

number.addQuery("category", tableName);

number.query()
if(number.next()) {

gs.print("Prefix:" + number.prefix);

prefix = number.prefix;

if(number.maximum_digits != numDigits) {

gs.print("old max digits:" + number.maximum_digits);

number.maximum_digits = numDigits;

number.update();

gs.print("new max digits:" + number.maximum_digits);

}

}


var tasks = new GlideRecord(tableName);

tasks.setWorkflow(false);

tasks.query();

while(tasks.next()) {

currentNumber = tasks.number.toString();

gs.print("Original Number:" + currentNumber);

currentNumber = currentNumber.split(prefix)[1];

if (currentNumber.length != numDigits) {

while(currentNumber.length < numDigits) {

currentNumber = "0" + currentNumber;

}

}

currentNumber = prefix + currentNumber;

tasks.number = currentNumber;

tasks.update();

gs.print("New Number:" + currentNumber);

}