How to custom auto-number records in a new table?

Dom Davidson
Giga Contributor

Hi All,

I am working on a requirement which requires a new attribute on a new table to be auto-generated in this format “YYYY-MM-DD-XXXXX”.  Where XXXXX is reset back to zero the next day.

How can I implement this?  I aware of the functionality of Number Maintenance module but I don't think that can facilitate this requirement. 

 

Much thanks for your input  🙂 

-Dominic

1 ACCEPTED SOLUTION

gregmelmoth
ServiceNow Employee
ServiceNow Employee

Do you need the number to be generated prior to inserting the record?

If not, you could do a Before Insert Business Rule that sets the attribute by counting the current number of created records today then increments that result by 1 and appends the Date.

 

If you need the attribute value to be assigned prior to inserting the record, you will most likely need to store and increment the number elsewhere more like the existing Auto-Number functionality. this coupled with a scheduled script to reset the count at the end of the day.

View solution in original post

3 REPLIES 3

balaji_prusty1
Giga Guru

Hi Dom;

 

You can write a script and update this auto number to 0 every day by scheduling it daily. So Everyday it will start from zero.

 

Thanks

Balaji Prusty

gregmelmoth
ServiceNow Employee
ServiceNow Employee

Do you need the number to be generated prior to inserting the record?

If not, you could do a Before Insert Business Rule that sets the attribute by counting the current number of created records today then increments that result by 1 and appends the Date.

 

If you need the attribute value to be assigned prior to inserting the record, you will most likely need to store and increment the number elsewhere more like the existing Auto-Number functionality. this coupled with a scheduled script to reset the count at the end of the day.

Dom Davidson
Giga Contributor

Thanks Greg,

 

I was able to push back on the reset back to zero requirement, and I was able to achieve the custom auto-numbering.  Leaving this piece of information here in the hopes it will help somebody(if so, don't forget to mark this answer as helpful)

 

- Firstly, I created an auto numbering record tailored to the new table I had on the Number Maintenance module.  It created a Number(u_number) field on the new table I had.

-  Then I created the following before insert business rule, and it did the trick.

 

find_real_file.png