Auto Numbering
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
04-29-2018 05:32 AM
I need to Populate Correlation ID on a Custom Table with numbers starting from 400000 and Incremented by 1 and If Possible need to Validate If number already exists.
Tried : javascript: global.getNextObjNumberPadded();
How Do I do this?
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
04-29-2018 07:54 PM
I tried this and its working fine. How do I confirm enabling that Property causes any effect on the existing FUnctionalities/ Work?
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
04-29-2018 08:31 PM
I do not think, it will cause any problem on existing functionalities/ Work, the new property will be in effect when you enabled it.
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
04-29-2018 08:34 PM
Adding to Shishir, Enabling this property can auto assign the number on any table onsubmit instead of onload.
Thanks.
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
04-29-2018 06:21 AM
Also,  javascript:getNextObjNumber(); 
Generate a unique number every time a form is loaded and if not saved it will skip the last generated number.
You can use below before BR to overcome this problem
(function executeRule(current, previous /*null when async*/) {
 var curr_max_num=10000000;
 var next_num=0;
 var gr = new GlideRecord('Custom Table Name'); 
 gr.addQuery('Field Name','CONTAINS','NUM'); 
 gr.query();
 while(gr.next())
 {
 var max_str=gr.'Field Name';
 var array = max_str.split('M');
 var recnum=parseInt(array[1]);
 if(recnum>curr_max_num)
 curr_max_num= recnum;
}
 var nxt_val=curr_max_num+1;
 var nxt_val_str='NUM'+nxt_val;
 current.'Field Name'=nxt_val_str;
})(current, previous);
Thanks
Neeraj
