Modifying number maintenance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 05:42 AM
1. What are the potential implications of changing the numbering system so that it display INCYYYYMMDD.0000 e.g. (INC20140925.0001)
2. Please advise how can this be technically achieved.
My thoughts are not to tamper with the OOTB functionality but to create a customer field. My concern is the maintenance of it. i.e.
- How would we handle user creating records are the same time.
- How do we reset the numbering and and how can we maintain this?
Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 06:02 AM
Hi Abdul,
You can get the current timestamp and concat it with INC.
What you will have to do is create a script Include and define a Custom Function where you will implement your Logic.
Now set the Default Value of the Number Column of your Table(in this case INC) with the Function call.
But yes, if the Number field is set as unique, then you will definitely face issues when two users will create tickets at the same Timestamp.
Thanks,
Subhajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:46 AM
The most difficult issue I foresee is ensuring we don't end up with the same number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2014 02:28 AM
Subhajit thanks for your idea. Just trying to extend your logic here is what I have so far:
Its a business rule, running on before insert. I am struggling on the logic to increment the number on a new record and resetting the number to zero each day. Can you help?
var curr_num;
var num;
var curr_bc_num;
var gdt =new GlideDateTime();//December
var month = '';
var dat ='';
var yea ='';
//gs.addInfoMessage(gdt.getDayOfMonth());
//gs.addInfoMessage(gdt.getMonth());
//gs.addInfoMessage(gdt.getYear());
var gr = new GlideRecord('incident');
gr.addOrCondition('sys_created_on', gs.daysAgoStart(1));
gr.query();
var count = gr.getRowCount();
//gs.addInfoMessage('Row Count ' + count + gs.daysAgoStart(-1));
while(gr.next()) {
curr_num = gr.number;
if (curr_num != 0) {
//gs.addInfoMessage('Inside If' + curr_num);
curr_bc_num = 'INC' + gdt.getDayOfMonth() + gdt.getMonth() + gdt.getYear() + '.';
num = parseInt("curr_num",8);
//gs.addInfoMessage('Integer of BC Number ' + num + 'Current Number ' + curr_num);
current.u_bc_number = curr_bc_num + num++;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2014 03:16 AM
Hi Abdul,
One thing that you can do is, keep the existing "Number" and its number maintenance, and use that to set the new number field. You can use this piece of code to populate this field:-
var gdt = new GlideDateTime();
var num="INC"+gdt.getYear()+gdt.getMonth()+gdt.getDayOfMonth()+".";
var str=current.number.toString();
var res = str.substring(4); //depends on the length of your current number
current.u_number=num+res;
Now you can write a scheduled job to reset the 'Number' field on number maintenance table for incident, so that every day the counter for last 4 digits is reset.
Regards,
Hari