Number Maintenance - Auto-Numbering Records

mferich
ServiceNow Employee
ServiceNow Employee

I know it is possible to set auto-numbering format as the prefix for new table records (such as INC for incidents or CHG for changes), but is it also possible to establish an auto-numbering suffix format?

 

For example: I want all new incident records to end in the suffix MAY (for the current month). Thus, when a new incident is created, the record is entered into the table with the number INC10001MAY. The next new incident contains the number INC10002MAY, followed by INC10003MAY, etc.

 

Thank you in advance!

1 ACCEPTED SOLUTION

Bhavesh Jain1
Giga Guru

Code :



var gdt =new GlideDateTime();//December


var month = '';


gs.print(gdt.getMonth());


if(gdt.getMonth() == 12)


month = 'DEC';


current.number = current.number + month;


View solution in original post

6 REPLIES 6

solutioningnow
Giga Guru

Hi,



There are two ways to suffix to the number.



Option 1: Modify OOB Global Business Rule "getNextObjNumberPadded" which generates number.


Option 2: Create display business rule on incident table. Please refer below script for your reference:


Condition : current.isNewRecord()


var gdt =new GlideDateTime();//December  


var month = '';  


if(gdt.getMonth() == 12)  


month = 'DEC';  


current.number = current.number + month;




Please mark answer as correct/helpful, if it was really helpful 🙂



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/


feroz4051
Mega Expert

using below BR to capture month from sys_created_on field of incident table. but no results.



BR: before /insert/ update:



script:


var date = getDate(current.sys_created_on);


var month = date.getMonth();


current.u_months = month;


gs.addInfoMessage(month);



[can't see addInfoMessage ]