Autoincrement string field for employee ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 01:39 PM
We have a field on the user table u_employee_id. It is a string field that contains only numbers. It has to have 6 digits even if it is only number 50 - so 000050 for example. The numbering was assigned in a random-ish way by human resources originally, so there are gaps... we might start at 000001 and go to 000059...and then skip to 000124.
I would like a business rule (I assume) that will auto increment and assign the next available number when a user is inserted. Filling in the gaps where they exist. Can anyone assist in the construction of this script? This seems to be a starting point:
Autoincrement stringfield (custom)
Thanks so much for any assistance you can provide!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 01:56 PM
The easiest way to do this is through Number Maintenance. Just add the table and number to the number Maintenance table, then add javascript:getNextObjNumberPadded(); to the default value of the field. This will not fill in the blanks, but will increment from the largest number.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 02:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2019 05:09 AM
a fair suggestion. But, I only want this to happen when there is not already an employee ID assigned... we have other users that are not employees that do not get an employee ID.