# Creating a Random fixed length ID

**URL:** <https://forums.knack.com/t/creating-a-random-fixed-length-id/17230>\
**Category:** Get Answers\
**Created:** [May 19, 2024, 10:52am UTC](https://forums.knack.com/t/creating-a-random-fixed-length-id/17230 "2024-05-19T10:52:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GSH](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/gsh/32/2669_2.png) [@GSH](https://forums.knack.com/u/GSH)\
**Post date:** [May 19, 2024, 10:52am UTC](https://forums.knack.com/t/creating-a-random-fixed-length-id/17230/1 "2024-05-19T10:52:18Z")

</div>

Hi there

Does anyone know how I can create a random 8 digital number that can then be used as an ID.

I want to be able to create a fixed length ID to associate with customer records. I understand that equation would be the way to go, but I am not sure how you can be sure that it will create somthing unique as there is no possibility to set this on the equation field.

Therefore a random number could not be unique when copied and set to the ID of the table record.

Hope that makes sense to knackers.

---

<div class="post-metadata">

**Author:** ![GrantSchuster](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/grantschuster/32/3311_2.png) [@GrantSchuster](https://forums.knack.com/u/GrantSchuster)\
**Post date:** [May 19, 2024, 11:44am UTC](https://forums.knack.com/t/creating-a-random-fixed-length-id/17230/2 "2024-05-19T11:44:12Z")

</div>

Knack’s got an explainer on a solution for this in the Builder Guide: [How to Set a Random ID](https://learn.knack.com/article/gknuie4fg3-how-to-set-a-random-id)

Looks like it uses text formula, but there is also a number equation:

random   
Get a random number between two values  
random(1,42) = 36.238172

combine that with floor, and you’ll have your number, but then use the conditional rule to copy it to the number field when blank (like in Knack instructions)

---

<div class="post-metadata">

**Author:** ![GSH](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/gsh/32/2669_2.png) [@GSH](https://forums.knack.com/u/GSH)\
**Post date:** [May 20, 2024, 4:47pm UTC](https://forums.knack.com/t/creating-a-random-fixed-length-id/17230/3 "2024-05-20T16:47:02Z")

</div>

So I got this down good. but the problem I have is that when the value is updated from a form the Random ID is not generated. When the value is updated from the knack builder it does.

In other words, if the field is blank in the knack data table view and I save it, it will assign the random ID to the text fied. When a new records is added to the table from a form, it does not creat the random ID
