- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 12:53 PM
Hello community,
I need to create an autoincrement field in Asset table.
I created new record in Numbers table [sys_number]
and Before Insert Business Rule with only one line (I have more complex logic for numbering, but for this example it doesn't matter) :
(function executeRule(current, previous /*null when async*/ ) {
current.comments = getNextObjNumberPadded();
})(current, previous);
I expect to see values like 0000136, 0000137, 0000138. But I see 0000136, 0000138, 0000140 and so on.
So Autoincrement doesn't work properly. I have +2 instead of +1 .
Where I can find last number? What table stores this one?
Thanks,
Best Regards, Eugene
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 08:25 AM
If you have set this up with the Numbers table, then the call to auto increment should already be created by the system. Then your additional call to getNextObjNumberPadded() causes the extra increment, resulting in +2 each time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 01:38 PM
Hi,
The current numbers are listed within the sys_number_counter table, you can get to it via sys_number_counter.list in left-hand navigation and press enter.
Or navigate to System Definition > Number Maintenance, click relevant record, then click 'Show counter' related link.
If this is a global table, there's already a global business rule that gets the next padded number, so it may be running both or something to that effect. You'd want to look things over a bit more.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 10:12 AM
Hello Eugene,
I'm glad you found a correct answer that worked for you.
I believe I covered that above in my reply and stated that there is already a business rule that gets the next padded number. Additionally, I answered at least one other question you had in your original post which is where are those numbers kept? I had already suggested that look things over and review this in addition to what you're already doing.
In any case, take care!
-Allen
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 01:43 PM
Hi, if the code was triggered twice before the record was saved then this would result in the behaviour you are seeing. Perhaps you could start by adding some debugging\logging in your script to confirm if the code runs twice and so is incrementing the number twice - Also perhaps something like this for testing.
current.comments = current.comments + ' | ' + getNextObjNumberPadded();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 08:25 AM
If you have set this up with the Numbers table, then the call to auto increment should already be created by the system. Then your additional call to getNextObjNumberPadded() causes the extra increment, resulting in +2 each time.