Skip to main content
June 17, 2008
Question

Unique LabelNumber

  • June 17, 2008
  • 1 reply
  • 371 views
I want to create a unique 6 character ID with numbers and letters. Without using the letters 'B', 'D', 'I', 'S' or 'O'.

I got this far but how can i mix the numbers and letters randomly to get the label. I'm stuck. Thanx.
This topic has been closed for replies.

1 reply

Inspiring
June 17, 2008
I would make this a function

goodchars = "0,1,2, etc ,A,C, etc";
lengthoflist = listlen(goodchars);
id = "";

for (i = 1; i gte 6; i = i + 1) {
id = listappend(id, listgetat(goodchars, randrange(1, lengthoflist);
}

<cfreturn id>

Then you test to see if the id has been used before, and keep calling it until you have a unique one.

Inspiring
June 17, 2008