Set the field to a consecutive first place number apart from the record number of the table

N_Y_1014
Tera Contributor

The premise is using a custom table that inherits the task.

 

The requirement is that we would like to have a unique number automatically populated in a field separate from the record number in the custom table that is counted for each record created.

Is it possible to achieve this requirement through scripting or other means?

 

As an example, we would like to have the following sequence of numbers.
*"ABC" and "CD" do not vary.
Example: ABC00000CD

 

Thank you in advance.

1 ACCEPTED SOLUTION

Barrilito van D
Kilo Guru

Hi,

This is something you would normally do on a table with a column that has autonumbering on it. You can look in the ui by typing (Number Maintenance) to see the coumns for each table. A table can have just one of those columns, so that works for a new custom table only. And as a sidenote, those auto number fields always have a prefix (a few characters) followed by the number. In your case you still want to add two characters after the number. I would recommend to reconsider that as nothing in ServiceNow has that kind of structure, but that is up to you.

Simple solution is: a "before insert" business rule where you just write some script to create the string with whatever you like in it based on anything you like and just write that to the field before the insert takes place.

 

If you think my answer put you in the right direction or you appreciated my effort, please mark the response as Helpful or mark my response as Correct.
Thanks in advance! Good luck!

View solution in original post

3 REPLIES 3

Barrilito van D
Kilo Guru

Hi,

This is something you would normally do on a table with a column that has autonumbering on it. You can look in the ui by typing (Number Maintenance) to see the coumns for each table. A table can have just one of those columns, so that works for a new custom table only. And as a sidenote, those auto number fields always have a prefix (a few characters) followed by the number. In your case you still want to add two characters after the number. I would recommend to reconsider that as nothing in ServiceNow has that kind of structure, but that is up to you.

Simple solution is: a "before insert" business rule where you just write some script to create the string with whatever you like in it based on anything you like and just write that to the field before the insert takes place.

 

If you think my answer put you in the right direction or you appreciated my effort, please mark the response as Helpful or mark my response as Correct.
Thanks in advance! Good luck!

N_Y_1014
Tera Contributor

@Barrilito van D 

Sorry for the late reply.
We were able to achieve our requirements by utilizing business rules.

Naga Ravindra R
Kilo Sage

Hey @N_Y_1014 

 

Can you please share some sample script? 

In my case, I have to something like below: CC-PPP-auto number in sequence. 

For example: CC-PPP-001, 002, 003...

Thank you