I've been watching this thread for a bit, but haven't chimed in, since it sounded like folks were solving the issue.
But now it is sounding far more complicated.
I had a similar need - Assign a random place in line for people making appointments coming to pick up free produce (food pantry). A random place was needed so that the same individuals wouldn't always be first in line.
Original solution was pre-javascript ban, but I think it can be adapted for folks who know piplines etc (I haven't ventured there yet). We have moved to a different appointment method, so this solution was no longer needed.
Parent table - Pantry dates - defines a date the pantry would be open, how many appointment could be made. Has a text field to hold a comma delimited list of random numbers, and a button to generate the numbers.
The button calls a .js code page, with parameters of the record id, and max number of random numbers to generate.
The code page generates the list of unique random numbers, and updates the Parent record with the list.
As appointments are added, each appointment is assigned the next random number in the list
Part([Line Numbers], [# of Produce appointments], ",")
Appointments are not allowed to be deleted, to prevent a number from being reused.
For this thread, if the child records already exist, then those versed in pipelines, could make a pipeline run through the list of records and assign the next random number in the parent list.
I think this fits the original random number issue the original poster had. It might not fit the greater discussion later posters have.
Hope this helps if someone needs a simple random number solution.
The pertinent javascript code for generating the random number line:
qb_maxnum is the maximum number to generate. Initialization forced anything lower than 10 to be 10.
The random number methodology I pulled from the web a number of years ago, and I believe the logic is solid.
function PopulateNumbers() {
/* First routine called. This will handle generating the array of random numbers.
Basic overview
Populate the array
Loop through the array to shuffle the numbers
*/
for (var widx = 0; widx < qb_maxnum; widx++) { // Load each number into the array
numberline[widx] = widx + 1;
} // end for loop load each number
numberstring = ""; //Clear it out
for (var widx = qb_maxnum - 1; widx > 0; widx--) { // Shuffle each number into the array
//select a random number (index) between 0 and the loop idx
randomnum = Math.floor(Math.random() * (widx));
tempnum = numberline[widx]; //save the value in the current spot
numberline[widx] = numberline[randomnum]; //swap it with the random value
numberline[randomnum] = tempnum; //replace value so its available
numberstring += numberline[widx] + ", "; // Tack the used number on the end of the number string
} // end for loop randomize each number
//Add the last number to the string
numberstring += numberline[0];
} //end populate number line
------------------------------
Andrea Best
------------------------------