Script for Unique number generation with 6 digit limit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2020 01:45 PM
Hi Forum,
Thanks in advance for helping me.
I have some requirement, we have some custom table with one custom number field, so would like to generate a unique number for this field based on the other reference field value, on the reference field we have some value, so whenever record insert into the main table we would like to get the reference field value (500) + newly generated unique value. How can I achieve this using BR.
EX: 500123456.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2020 02:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2020 11:37 AM
Thanks for the replay, but I can't go with number maintenance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2020 02:35 PM
Hi, I would suggest you use number maintainence to increment a number in 1 field, and in another field concatenate the reference field and the number on insert. But this new concatenated number will not show until after the record is saved, and you may be able to use a client script to to set the value before insert on the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2020 02:46 PM
Hi,
Below Business Rule code will help you to create a unique random number.
var max=600000
var min=500000//create a random unique number from 500000
current.u_auto_number=Math.floor(Math.random() * (max- min)) + min;
OR
You can also set a unique random number by the default value of the field to
javascript:current.u_auto_number=Math.floor(Math.random() * (600000 - 50000)) + 50000;
Hope this helps!
Please mark the reply as Helpful/Correct, if applicable.
Regards,
Hemant